If gcc was build for MinGW with specific --native-system-header-dir than 'mingw/include' is still added to include search path. Test compilation: $ echo int main(){return 1;} | i686-w64-mingw32-gcc.exe -pipe -m32 -v -x c - Using built-in specs. COLLECT_GCC=i686-w64-mingw32-gcc.exe COLLECT_LTO_WRAPPER=t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../libexec/gcc/i686-w64-mingw32/4.7.2/lto-wrapper.exe Target: i686-w64-mingw32 Configured with: ../../source/gcc-4.7.2/configure --build=i686-pc-mingw32 --host=i686-pc-mingw32 --target=i686-w64-mingw32 --disable-nls --disable-multilib --prefix=/home/UserName/mingw-w64/mingw-w64-i686 --with-sysroot=/home/UserName/mingw-w64/mingw-w64-i686 --with-native-system-header-dir=/i686-w64-mingw32/include --with-host-libstdcxx=/mingw/lib/gcc/mingw32/4.7.2/libstdc++.a --disable-cloog-version-check --disable-ppl-version-check --with-mpc=/home/UserName/mingw-w64/packages/gcc/packages/mpc/mpc-1.0.1-i686 --with-mpfr=/home/UserName/mingw-w64/packages/gcc/packages/mpfr/mpfr-3.1.1-i686 --with-gmp=/home/UserName/mingw-w64/packages/gcc/packages/gmp/gmp-5.1.0-i686 --with-ppl=/home/UserName/mingw-w64/packages/gcc/packages/ppl/ppl-1.0-i686 --with-cloog=/home/UserName/mingw-w64/packages/gcc/packages/cloog-ppl/cloog-ppl-0.15.11-i686 --enable-languages=c,c++ --enable-threads=win32 --enable-fully-dynamic-string --disable-sjlj-exceptions --with-multilib-list=m32 --with-arch=pentium3 --enable-leading-mingw64-underscores --with-dwarf2 --enable-lto --disable-win32-registry --with-win32-nlsapi=unicode --enable-libstdcxx-debug Thread model: win32 gcc version 4.7.2 (GCC) COLLECT_GCC_OPTIONS='-pipe' '-m32' '-v' '-mtune=generic' '-march=pentium3' t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../libexec/gcc/i686-w64-mingw32/4.7.2/cc1.exe -quiet -v -iprefix t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../lib/gcc/i686-w64-mingw32/4.7.2/ -isysroot t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../../mingw-w64-i686 -U_REENTRANT - -quiet -dumpbase - -m32 -mtune=generic -march=pentium3 -auxbase - -version -o - | t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/as.exe -v --32 -o C:\Users\UserName\AppData\Local\Temp\ccG0majQ.o GNU assembler version 2.23.1 (i686-w64-mingw32) using BFD version (GNU Binutils) 2.23.1 GNU C (GCC) version 4.7.2 (i686-w64-mingw32) compiled by GNU C version 4.7.2, GMP version 5.1.0, MPFR version 3.1.1-p2, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "T:/MinGW32/msys/1.0/home/UserName/mingw-w64/mingw-w64-i686/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.7.2/include" ignoring nonexistent directory "t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../../mingw-w64-i686T:/MinGW32/msys/1.0/home/UserName/mingw-w64/mingw-w64-i686/lib/gcc/i686-w64-mingw32/4.7.2/../../../../include" ignoring duplicate directory "T:/MinGW32/msys/1.0/home/UserName/mingw-w64/mingw-w64-i686/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.7.2/include-fixed" ignoring duplicate directory "T:/MinGW32/msys/1.0/home/UserName/mingw-w64/mingw-w64-i686/lib/gcc/../../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include" ignoring nonexistent directory "t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../../mingw-w64-i686/mingw/include" #include "..." search starts here: #include <...> search starts here: t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../lib/gcc/i686-w64-mingw32/4.7.2/include-fixed t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/include End of search list. GNU C (GCC) version 4.7.2 (i686-w64-mingw32) compiled by GNU C version 4.7.2, GMP version 5.1.0, MPFR version 3.1.1-p2, MPC version 1.0.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 15f70762a5e5104aa198de43826cad3c COMPILER_PATH=t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../libexec/gcc/i686-w64-mingw32/4.7.2/;t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../libexec/gcc/;t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ LIBRARY_PATH=t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/;t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/;t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/lib/../lib/;t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/lib/ COLLECT_GCC_OPTIONS='-pipe' '-m32' '-v' '-mtune=generic' '-march=pentium3' t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../libexec/gcc/i686-w64-mingw32/4.7.2/collect2.exe --sysroot=t:\mingw32\msys\1.0\home\username\mingw-w64\mingw-w64-i686\bin\../../mingw-w64-i686 -m i386pe -Bdynamic t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/lib/../lib/crt2.o t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/crtbegin.o -Lt:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2 -Lt:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc -Lt:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/lib/../lib -Lt:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/lib C:\Users\UserName\AppData\Local\Temp\ccG0majQ.o -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_eh -lgcc -lmoldname -lmingwex -lmsvcrt t:/mingw32/msys/1.0/home/username/mingw-w64/mingw-w64-i686/bin/../lib/gcc/i686-w64-mingw32/4.7.2/crtend.o
This unwanted dir is added by blindly overriding directory in gcc/config/i386/mingw32.h: #undef NATIVE_SYSTEM_HEADER_DIR #define NATIVE_SYSTEM_HEADER_DIR "/mingw/include" as result of fixing bug 52947. I think, it needs more improvement. At least for MinGW this directory should be relative to GCC files, as other include dirs. And cppdefault.c should be corrected like this: #ifdef NATIVE_SYSTEM_HEADER_DIR /* /usr/include comes dead last. */ { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, NATIVE_SYSTEM_HEADER_DIR_ADD_SYSROOT, 0 }, #endif similar to GPLUSPLUS_INCLUDE_DIR part in cppdefault.c.
Result on MinGW32 compiler (tried from mingw site or compiled from sources - results are the same): $ echo int main(){return 1;} | gcc.exe -v -E -x c - Using built-in specs. COLLECT_GCC=gcc.exe Target: mingw32 Configured with: ../gcc-4.7.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --disable-build-poststage1-with-cxx --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.7.2 (GCC) COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=i386' '-march=i386' t:/mingw32/bin/../libexec/gcc/mingw32/4.7.2/cc1.exe -E -quiet -v -iprefix t:\mingw32\bin\../lib/gcc/mingw32/4.7.2/ - -mtune=i386 -march=i386 ignoring nonexistent directory "t:\mingw32\bin\../lib/gcc/mingw32/4.7.2/../../../../mingw32/include" ignoring duplicate directory "t:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.2/include" ignoring nonexistent directory "/mingw/include" ignoring duplicate directory "t:/mingw32/lib/gcc/../../include" ignoring duplicate directory "t:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.2/include-fixed" ignoring nonexistent directory "t:/mingw32/lib/gcc/../../lib/gcc/mingw32/4.7.2/../../../../mingw32/include" ignoring nonexistent directory "/mingw/include" #include "..." search starts here: #include <...> search starts here: t:\mingw32\bin\../lib/gcc/mingw32/4.7.2/include t:\mingw32\bin\../lib/gcc/mingw32/4.7.2/../../../../include t:\mingw32\bin\../lib/gcc/mingw32/4.7.2/include-fixed End of search list. # 1 "<stdin>" # 1 "<command-line>" # 1 "<stdin>" int main(){return 1;} COMPILER_PATH=t:/mingw32/bin/../libexec/gcc/mingw32/4.7.2/;t:/mingw32/bin/../libexec/gcc/;t:/mingw32/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ LIBRARY_PATH=t:/mingw32/bin/../lib/gcc/mingw32/4.7.2/;t:/mingw32/bin/../lib/gcc/;t:/mingw32/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/lib/;t:/mingw32/bin/../lib/gcc/mingw32/4.7.2/../../../ COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=i386' '-march=i386' Two "/mingw/include" in Posix format in GCC! In practice GCC try to use /mingw/include directory on current drive (in my case on drive T: ), but I may have a different MinGW version installed there.