Menu

#221 Build error with mingw: ‘SYSTEM_POWER_STATUS’ has no member named ‘Reserved1’

Unscheduled
closed
nobody
None
Bug
5
2024-04-01
2024-03-01
No

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)

Discussion

  • Ashok P. Nadkarni

    Noted. Thanks.

     
  • Anonymous

    Anonymous - 2024-03-15

    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 package mingw-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/cc897d8fb814d82c984eb0285d9347d4041e6d1a

    There 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.

     
  • Konstantin Kushnir

    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.

     
  • Ashok P. Nadkarni

    • status: open --> closed
     
  • Ashok P. Nadkarni

     

Anonymous
Anonymous

Add attachments
Cancel