How to include Window.h


#1

I sometimes would like to use certain functions for testing from the win32 api, but it won’t always compile without errors. Right now I’m tinkering with outliner_draw.c

What should I know about #include <Windows.h> to get it to compile?


#2

While its not recommended given this header doesn’t exist on other platforms we support, a simple

#include <windows.h> 

should work, if i doesn’t you’ll have to be more forth coming with a build log or a specific error


#3

It’s not compiling. Here is the build log:

1>------ Build started: Project: locales, Configuration: Debug x64 ----


2>------ Build started: Project: bf_editor_space_outliner, Configuration: Debug x64 ------
3>------ Build started: Project: buildinfo, Configuration: Debug x64 ------
3>Generating buildinfo.h_fake, buildinfo.h
2>outliner_draw.c
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\minwindef.h(247): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared\minwindef.h(248): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(213): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(213): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(213): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(214): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(221): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(221): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(221): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(223): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(232): error C2146: syntax error: missing ‘)’ before identifier ‘phkResult’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(232): error C2081: ‘PHKEY’: name in formal parameter list illegal
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(232): error C2061: syntax error: identifier ‘phkResult’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(232): error C2059: syntax error: ‘;’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(233): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(241): error C2146: syntax error: missing ‘)’ before identifier ‘phkResult’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(241): error C2081: ‘PHKEY’: name in formal parameter list illegal
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(241): error C2061: syntax error: identifier ‘phkResult’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(241): error C2059: syntax error: ‘;’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(242): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(265): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(265): error C2146: syntax error: missing ‘)’ before identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(265): error C2061: syntax error: identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(265): error C2059: syntax error: ‘;’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(265): error C2059: syntax error: ‘,’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(267): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(273): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(273): error C2146: syntax error: missing ‘)’ before identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(273): error C2061: syntax error: identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(273): error C2059: syntax error: ‘;’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(273): error C2059: syntax error: ‘,’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(275): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(287): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(287): error C2146: syntax error: missing ‘)’ before identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(287): error C2061: syntax error: identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(287): error C2059: syntax error: ‘;’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(287): error C2059: syntax error: ‘,’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(290): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(296): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(296): error C2146: syntax error: missing ‘)’ before identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(296): error C2061: syntax error: identifier ‘hKey’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(296): error C2059: syntax error: ‘;’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(296): error C2059: syntax error: ‘,’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(299): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(310): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(310): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(310): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(313): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(318): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(318): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(318): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(321): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(332): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(332): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(332): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(341): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(347): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(347): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(347): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(356): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(368): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(368): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(368): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(379): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(384): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(384): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(384): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(395): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(406): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(406): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(406): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(408): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(413): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(413): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(413): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(415): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(426): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(426): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(426): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(430): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(436): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(436): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(436): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(440): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(452): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(452): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(452): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(458): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(463): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(463): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(463): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(469): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(480): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(480): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(480): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(481): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(487): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(487): error C2143: syntax error: missing ‘{’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(487): error C2059: syntax error: ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(488): error C2059: syntax error: ‘)’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(494): error C2143: syntax error: missing ‘)’ before ‘constant’
2>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\winreg.h(494): fatal error C1003: error count exceeds 100; stopping compilation
2>Done building project “bf_editor_space_outliner.vcxproj” – FAILED.
4>------ Build started: Project: blender, Configuration: Debug x64 ------
4>buildinfo.c
4>blender.vcxproj -> C:\BlenderSrc\build_windows_Full_x64_vc15_Release\bin\Debug\blender.exe
========== Build: 3 succeeded, 1 failed, 127 up-to-date, 0 skipped ==========


#4

try putting #undef HKEY before your include.


#5

Yeah, that fixed it. How did you determine that to be the problem?


#6

Bumped into it before, but without a build log it’s hard to guess at things like this.