Including windows.h in 4.20 causes _WIN32_WINNT_WIN10 is not defined errors

Hi,

We’ve made a plugin that allows reading and writing to a shared memory. It works in 4.19 and it relies on including windows.h to enable functions like OpenFileMapping etc.

However, when including windows.h in 4.20 plugin I am getting:

_WIN32_WINNT_WIN10_TH2 is not defined as a preprocessor macro errors.

Has anyone found a way to mitigate this issue?

I tested this on a blank C++ project where I added a Blueprint function library plugin. The error appears the moment you insert #include <Windows.h> line.

this is my exact problem, the included sqlite support plugin has a #include windows.h and is causing compile errors similar to yours!

HEY BRADR!! i figured it out. If you take a look at VCToolChain.cs you will find CompileEnvironment.bEnableUndefinedIdentifierWarnings !

Which means if you go to your ProjectFolder\ProjectName.Build.cs and use bEnableUndefinedIdentifierWarnings = false as compile option (above PublicDependencyModuleNames) it will compile!

additionally if you visit Engine\Source\Programs\UnrealBuildTool\Configuration\ModuleRules.cs you can find bEnableUndefinedIdentifierWarnings and set to false there for all engine projects to have it disabled also!

I got advice from Epic (Thanks Martin S.!) that instead of using:

#include Windows.h

I should use:
#include "Windows/MinWindows.h.

It worked.

Apparently, Epic didn’t like original Windows.h and made their own (MinWindows.h) which turns off some features they don’t like.

All I had to do then was to rewrite min(a,b) function, because apparently its not included in the MinWindows.h.

2 Likes

Thanks man ! It works perfectly now ! It really saved me !

Hey did you find a solution for that issue?
The answers posted here don’t work for me.

check @mitjaprelovsek answer : you should use “Windows/MinWindows.h” instead of “windows.h”.

I assumed the answer was posted by someone else.
Anyway, that solution does not work for me. The same errors popup.

I tried that. Does not work for me. Same errors show up.