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.
54typedef long _off_t;
57typedef _off_t off_t;
59#endif /* Not _OFF_T_ */
_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 :
23 #include <errno.h>
24 #ifdef _MSC_VER
25 /* enable posix for limits.h and only limits.h
26 enabling it for all msvc headers will potentially
27 disable a lot of commonly used msvcrt functions */
28 #define _POSIX_
29 #include <limits.h>
30 #undef _POSIX_
32 #include <limits.h>
34 #include <stdarg.h>
35 #include <stddef.h>
36 #include <stdlib.h>
37 #include <time.h>
38 #include <string.h>
39 #include <sys/types.h>
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 :
24 #include <sys/types.h>
26/* 4 Gig max offsets if sys/types doesn't exist. */
27typedef unsigned int off_t;
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.