[cfe-dev] Compiler error including windows.h

Edward Diener via cfe-dev cfe-dev at lists.llvm.org
Sun May 7 21:09:11 PDT 2017


On 5/7/2017 10:52 PM, Nico Weber via cfe-dev wrote:
> It's a bug in the mingw headers. If you pass -fms-extensions 
> -fms-extensions, clang will accept that code since Microsoft's headers 
> have the same bug.

BTW using the clang-4.0 distribution with '-target i686-pc-windows-gnu' 
as a compiler and linker option, everything works correctly.

> 
> On May 7, 2017 10:05 PM, "Edward Diener via cfe-dev" 
> <cfe-dev at lists.llvm.org 
> <mailto:cfe-dev at lists.llvm.org>> wrote:
> 
>     I build clang from the latest source using mingw-64/gcc-7.1. Using
>     mingw-64/gcc-7.1 as the backend, when I compile:
> 
>     // test_compiler.cpp
> 
>     #include <windows.h>
>     int main()
>     {
>     return 0;
>     }
> 
>     with the command line:
> 
>     some_path/clang++" -c -x c++ -O0 -g -fno-inline -Wall -g -march=i686
>     -m32" -o "some_path\test_compiler.obj" "test_compiler.cpp"
> 
>     I get:
> 
>     In file included from test_compiler.cpp:1:
>     In file included from
>     C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\windows.h:69:
>     In file included from
>     C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\windef.h:8:
>     In file included from
>     C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\minwindef.h:163:
>     C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\winnt.h:4720:18:
>     error: default initialization of an object of const type 'const
>     GUID' (aka 'const _GUID') without a user-provided default constructor
>          DEFINE_GUID (GUID_MAX_POWER_SAVINGS, 0xa1841308, 0x3541,
>     0x4fab, 0xbc, 0x81, 0xf7, 0x15, 0x56, 0xf2, 0x0b, 0x4a);
>                       ^
>     C:\Utilities\mingw-w64\i686-7.1.0-posix-dwarf-rt_v5-rev0\mingw32\i686-w64-mingw32\include\winnt.h:4721:18:
>     error: default initialization of an object of const type 'const
>     GUID' (aka 'const _GUID') without a user-provided default constructor
>          DEFINE_GUID (GUID_MIN_POWER_SAVINGS, 0x8c5e7fda, 0xe8bf,
>     0x4a96, 0x9a, 0x85, 0xa6, 0xe2, 0x3a, 0x8c, 0x63, 0x5c);
>                       ^
> 
>     etc. with the same errors for all the other DEFINE_GUID s in winnt.h
> 
>     Needless to say compiling the same source with mingw-64/gcc-7.1
>     directly succeeds.
> 
>     Is this a bug in the latest clang source ?




More information about the cfe-dev mailing list