Compile error when including windows.h

Hello guys,

I’m currently facing an Issue where I get these two compile errors:

error C3668: 'UTextureCube::UpdateResourceW': method with override specifier 'override' did not override any base class methods
error C3668: 'UCanvasRenderTarget2D::UpdateResourceW': method with override specifier 'override' did not override any base class methods

when I include windows in a source file like this:

#define WIN32_LEAN_AND_MEAN
#include "Windows.h"

Interestingly enough is, that the Issue still exists even if don’t include anything else except that header and even if i don’t have and source using it.

I don’t think you’re able to include windows.h in your project as of UE 4.20, but I could be wrong. According to Including windows.h in 4.20 causes _WIN32_WINNT_WIN10 is not defined errors - Plugins - Unreal Engine Forums and c++ - Upgrading UE4.19 project to 4.20 - Stack Overflow you might want to include “Windows/MinWindows.h”.

Although, the error message you’re seeing appears to be different from those linked posts, and one commentor suggested defining WIN32_LEAN_AND_MEAN as a workaround.

If possible I might still try switching to “Windows/MinWindows.h” and seeing if the error persists, as long as the header provides all the functionality you need.

I found the answer.

You need to include Engine.h first.

To improve compile times, you may want to include “CoreMinimal.h” instead of “Engine.h” (provided of course, that it still compiles when doing so). See IWYU | Unreal Engine Documentation for more.

I’m used to doing that but for some reason just CoreMinimal.h didn’t work… Engine.h did…