Build error with mingw: ‘SYSTEM_POWER_STATUS’ has no member named ‘Reserved1’
Brought to you by:
apnadkarni
Hello!
I have the following error when compiling with Mingw:
C:/DriveD/Projects/installkit/src/twapi/twapi/base/tclobjs.c: In function ‘ObjFromSYSTEM_POWER_STATUS’:
C:/DriveD/Projects/installkit/src/twapi/twapi/base/tclobjs.c:2166:30: error: ‘SYSTEM_POWER_STATUS’ has no member named ‘Reserved1’
2166 | objv[3] = ObjFromInt(spsP->Reserved1);
| ^~
make[1]: *** [Makefile:314: tclobjs.o] Error 1
make[1]: Leaving directory '/c/DriveD/Projects/installkit/build/Windows/work/twapi'
The struct SYSTEM_POWER_STATUS
has SystemStatusFlag
sine this commit: https://github.com/mirror/mingw-w64/commit/bae5878fcb3e0f0eb034814213d9ec35260de913
I have to changed the line https://github.com/chpock/twapi/blob/fc670d0f6e7e3659cb778eda7b0f69dea1799f59/twapi/base/tclobjs.c#L2163 from:
#if _MSC_VER >= 1900
to:
#if _MSC_VER >= 1900 || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 7)
Anonymous
Noted. Thanks.
It seems that relying on the mingw version is not quite correct.
This member exists in Cygwin package
mingw64-i686-headers-11.0.1-1
in/usr/i686-w64-mingw32/sys-root/mingw/include/winbase.h
, however it doesn't exist in Ubuntu packagemingw-w64-common
v8.0.0-1 in/usr/share/mingw-w64/include/winbase.h
.Also, the above link to mingw commit refers to
mingw-w64-tools/widl
headers. But general headers where patched just a year ago, and this version hasn't been released yet: https://github.com/mirror/mingw-w64/commit/cc897d8fb814d82c984eb0285d9347d4041e6d1aThere doesn't seem to be a way to use this structure member conditionally based on the usual definitions. Perhaps the best way is to implement check in autoconf and define some definition based on this check.
I ended up with the following changes: https://github.com/chpock/twapi/pull/2
It now works in both of my environments, Cygwin and Ubuntu.
Fixed in 5.0 at https://github.com/apnadkarni/twapi