Menu ▾ ▴

#1038 `winnt.h` cannot be included standalone

v1.0 (example)
open
nobody
None
5
6 days ago
6 days ago
Jacek Sieka
No

consider a simple C file:

#include <winnt.h>

It appears that CONST is not defined:

clang --target=x86_64-mingw32 -c /tmp/test.c
In file included from /tmp/test.c:1:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:315:11: error: unknown type name 'CONST'
  315 |   typedef CONST WCHAR *LPCWCH,*PCWCH;
      |           ^
/usr/x86_64-w64-mingw32/sys-root/mingw/include/winnt.h:315:22: error: expected ';' after top level declarator
  315 |   typedef CONST WCHAR *LPCWCH,*PCWCH;
      |                      ^

an include of minwindef.h solves the issue:

clang --target=x86_64-mingw32 -c -include /usr/x86_64-w64-mingw32/sys-root/mingw/include/minwindef.h /tmp/test.c

While the standard way of including windows is through windows.h, it's convenient to have each header file be include-ready standalone since this helps code inspectors and parsers - in this particular case, I'm looking to parse the header to generate bindings for a different language (Nim).

Discussion


Log in to post a comment.