Compiler error including windows.h

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler error including windows.h

Nat! via cfe-dev
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 ?





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Compiler error including windows.h

Nat! via cfe-dev
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.

On May 7, 2017 10:05 PM, "Edward Diener via cfe-dev" <[hidden email]> 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 ?





_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Compiler error including windows.h

Nat! via cfe-dev
On 2017/5/8 10:52, 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.
Is it? Despite lack of a constructor the structure `GUID` is an
aggregate, so aggregate initialization takes place. We do use the
aggregate initialization syntax in our headers which is the same in C,
C++98 and C++11, so there is no need to define a constructor explicitly.

--
Best regards,
LH_Mouse

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Compiler error including windows.h

Nat! via cfe-dev
In reply to this post by Nat! via cfe-dev
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"
> <[hidden email]
> <mailto:[hidden email]>> 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 ?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Compiler error including windows.h

Nat! via cfe-dev
In reply to this post by Nat! via cfe-dev
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.

I need to pass -fms-extensions twice ? I tried passing -fms-extensions
once and the same error occurs. Needless to say when using
mingw-64/gcc-7.1 -fms-extensions is not being passed and it is working
correctly.

>
> On May 7, 2017 10:05 PM, "Edward Diener via cfe-dev"
> <[hidden email]
> <mailto:[hidden email]>> 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 ?
>
>
>
>
>
>     _______________________________________________
>     cfe-dev mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>     <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
>
>
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev