gcc version 4.1.2 from http://ftp.gnu.org/gnu/gcc/gcc-4.1.2/gcc-core-4.1.2.tar.bz2 when compiled with --target=i686-pc-mingw32 on host i686-pc-linux-gnu has trouble when it compiles /gcc-4.1.2/libiberty/fopen_unlocked.c under certain conditions.
Here is where the error occurs: /opt/build/gcc-i686-pc-mingw32/./gcc/xgcc -B/opt/build/gcc-i686-pc-mingw32/./gcc/ -B/opt/mingw32/i686-pc-mingw32/bin/ -B/opt/mingw32/i686-pc-mingw32/lib/ -isystem /opt/mingw32/i686-pc-mingw32/include -isystem /opt/mingw32/i686-pc-mingw32/sys-include -c -DHAVE_CONFIG_H -O2 -g -O2 -I. -I/opt/build/gcc-4.1.2/libiberty/../include -W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes /opt/build/gcc-4.1.2/libiberty/fopen_unlocked.c -o fopen_unlocked.o In file included from /opt/build/gcc-4.1.2/libiberty/fopen_unlocked.c:73: /opt/mingw32/i686-pc-mingw32/sys-include/stdio_ext.h:47: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern' /opt/mingw32/i686-pc-mingw32/sys-include/stdio_ext.h: In function '__freading': /opt/mingw32/i686-pc-mingw32/sys-include/stdio_ext.h:52: error: expected declaration specifiers before '__THROW' /opt/mingw32/i686-pc-mingw32/sys-include/stdio_ext.h:57: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__THROW' ... This problems is caused by these lines in fopen_unlocked.c: ----- #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #ifdef HAVE_STDIO_EXT_H #include <stdio_ext.h> #endif #include "libiberty.h" ----- They need to be: ----- #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdio.h> #ifdef HAVE_STDIO_EXT_H #include <sys/cdefs.h> /* Added - need sys/cdefs.h (or features.h) before stdio_ext.h - for *_DECLS */ #include <stdio_ext.h> #endif #include "libiberty.h" ----- Lines 43 and 85 of /opt/mingw32/i686-pc-mingw32/sys-include/stdio_ext.h (which is placed there with the fixincludes code) have __BEGIN_DECLS and __END_DECLS but looking at the -save-temps ".i" file they are not defined prior. The file /usr/include/sys/cdefs.h is where "__BEGIN_DECLS" and "__END_DECLS" is defined. File "cdefs.h" does mention that it could be included by way of features.h but that is unneccesary. Anytime we use "#include <stdio_ext.h>" we must first use "#include <sys/cdefs.h>" on host Debian GNU/Linux version 2.6.17 --target=i686-pc-mingw32 cross-compiled from i686-pc-linux-gnu. # /lib/libc.so.6 GNU C Library stable release version 2.6, by Roland McGrath et al. # /opt/build/gcc-i686-pc-mingw32/gcc/xgcc -v Using built-in specs. Target: i686-pc-mingw32 Configured with: /opt/colinux/build/gcc-4.1.2/configure -v --prefix=/opt/colinux/mingw32 --target=i686-pc-mingw32 --with-headers=/opt/colinux/mingw32/i686-pc-mingw32/include --with-gnu-as --with-gnu-ld --disable-nls --without-newlib --disable-multilib --enable-languages=c,c++ Thread model: win32 gcc version 4.1.2 If it is agreed that this is a bug then you will want to update http://ftp.gnu.org/gnu/gcc/gcc-4.1.2/gcc-core-4.1.2.tar.bz2 -- Summary: fopen_unlocked.c missing include file for MinGW cross compile Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rob1weld at aol dot com GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-mingw32 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32473