Interestingly, an include file of mine has been rejected by my compiler.
The file is "allegro_image.h".
My compiler says that al_init_image_addon and al_shutdown_image_addon have not been declared. I am using the static version of Allegro 5.0.7.
Allegro works absolutely fine without this one, though I kinda need it to draw bitmaps... :|
After those complaints, it goes on to say "expected constructors, destructors of '{
' before ';', but I think that's just because it didn't recognise the functions.
I would diagnose these, but I don't understand the #ifndef and other stuff in the file...
I have been using Code::blocks and the mingw g++ compiler, and nothing has gone wrong so far. (since I started using an IDE)
Please help, I can't draw any bitmaps until I get this working...
Please post your code.
allegro_image.h -> This file has been unedited from it's download and install
Hope that helps
That's not your code. Your code looks exactly like:
#include <allegro5/allegro_image.h>
Exactly, and that is the code that is throwing the error!
If I remove the link to the allegro_image.h file, it works fine!
But here's mine, single file, main.cpp.
Exchange lines 3 and 4, so that allegro.h is included first.
exactly like:
#include <allegro5/allegro_image.h>
#include "allegro5/allegro_image.h"
Yep, that was it.
I had no idea that the order of includes could affect building...
Then again, I've never had more than 3 include files before...
Many thanks for your quick help, you guys are awesome, just sayin'.
Keep it awesome!
RazorSharpFang
I had no idea that the order of includes could affect building...
When the preprocessor includes files, it copies the contents of them into the file that was including them, putting them where the directive was written. This is why the order is important.
You should give credit to everyone who helped.
Also please try to make an effort to investigate and understand what's going on and WHY you needed to make that change.
Oh. That's what credit means! (I understand now!)
Incidentally, I did manage to get it to compile, but after editing the allegro_image.h file a lot, which would probably impede it's cross-platform nature.
I suspect now that the allegro.h or the include of allegro.h have #defines which would change the preprocessor's output, which would cause differences if the files were included in a different order.
Wow, I'm learning a lot from this. I should come here more often.
after editing the allegro_image.h file a lot
You normally shouldn't do that. Especially if you want to use it again You can set the directory where GCC searches for include files with -I.
I suspect now
It's much simpler than that.
Actually, he's exactly right as to why they need to be included in that order. allegro_image.h requires ALLEGRO_MSVC to be defined if it is running on Microsoft's compiler while utilizing DLLs. If allegro.h is included, then platform/almsvc.h will be automatically included through Allegro's internal/ header-set. If allegro_image.h is included before allegro.h, it does not recognize that it must use a declspec to declare the functions and, thus, MSVC assumes that it must be declared inside of the executable and this results in a not-defined error.