I compiled Allegro 5 using MinGW with no problems. I was even able to compile projects fine. Then today I updated stdlib.h and wchar.h in order to make MinGW compile without error when passing -std=c++11. Oddly enough, after updating those two files and recompiling the simple display code:
I get 5 errors:
c:\mingw\include\allegro5\file.h|34|error: expected identifier before '*' token|
c:\mingw\include\allegro5\file.h|34|error: 'off_t' declared as function returning a function|
c:\mingw\include\allegro5\fshook.h|75|error: expected identifier before '*' token|
c:\mingw\include\allegro5\fshook.h|75|error: 'off_t' declared as function returning a function|
c:\mingw\include\allegro5\fshook.h|101|error: 'off_t' does not name a type|
The lines in question:
file.h line 34:
AL_METHOD(off_t, fi_fsize, (ALLEGRO_FILE *f));
fshook.h line 75
AL_METHOD(off_t, fs_entry_size, (ALLEGRO_FS_ENTRY *e));
fshook.h line 101
AL_FUNC(off_t, al_get_fs_entry_size,(ALLEGRO_FS_ENTRY *e));
Don't understand why it worked before and now I get these errors. The last one makes no sense since both files have typedef unsigned int off_t;.
This kind of reminds me when I tried to compile some C++11 code using a cross-compiler and produced a similar error. I fixed it by passing -std=gnu++11 instead.
Maybe I'm kind of misunderstanding but, have you tried passing -std=gnu++11 instead of the other?
Yeah, it compiles fine with -std=gnu++11, but you have to be careful as it loads extensions that aren't part of the standard so if you use them your code may not compile under another compiler. Making it work with -std=c++11 gives me a side project to do though.
For reference I'm looking at MinGW gcc and stdlib c++ 5.3.0 with mingwrt 3.21.1. I'm also assuming you're talking about the stdlib.h and the wchar.h from the MinGW users mailing list.
Did you try recompiling Allegro? And see if it still worked after your updates?
Why don't you look at the updated stdlib.h and wchar.h and see what changed? The diff program will tell you exactly what is different.
wchar.h includes sys/types.h. Both versions. wchar.h is never included by Allegro.
stdio.h includes sys/types.h as well (which you included in your program)
sys/types.h defines _off_t and off_t on lines 54 and 57.
_NO_OLDNAMES is probably defined when -std=c++11, but I couldn't say for sure. Which would mean that off_t is undefined.
And in allegro/include/allegro5/file.h we have :
And in allegro/include/allegro5/base.h we have :
So if standard headers are included (#ifndef ALLEGRO_NO_STD_HEADERS) we have sys/types.h included, but it doesn't define off_t in the case of _NO_OLDNAMES, so file.h won't compile.
In the case of fshook.h it's a little different :
Considering that MinGW has sys/types.h, it would make sense to assume that ALLEGRO_HAVE_SYS_TYPES_H would be defined, and therefore sys/types.h would be included (which doesn't define off_t in the case of _NO_OLDNAMES), leaving off_t undefined.
That would explain both cases in your compile test, as long as _NO_OLDNAMES is undefined it will work, but when it is, it won't.
The real difference here is compiling with -std=c++11. It has nothing to do with any of the changes in the headers. Try compiling with and without the c++11 flag. It should work without it, and fail with it.
That was the problem.