Suddenly can't compile (Error C4668)

I was having no problems until I added #include <string> to one of my header files. Even after removing that line though, I still get the following errors:

  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winnt.h(584): warning C4005: 'TEXT': macro redefinition
  c:\program files\epic games\ue_4.22\engine\source\runtime\core\public\HAL/Platform.h(904): note: see previous definition of 'TEXT'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7542): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7548): error C4668: '_WIN32_WINNT_WIN10_RS1' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7553): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7557): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7564): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7574): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7578): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7583): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7777): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12249): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12266): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12285): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12404): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  [4/7] SurfaceCheck.cpp
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winnt.h(584): warning C4005: 'TEXT': macro redefinition
  c:\program files\epic games\ue_4.22\engine\source\runtime\core\public\HAL/Platform.h(904): note: see previous definition of 'TEXT'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7542): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7548): error C4668: '_WIN32_WINNT_WIN10_RS1' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7553): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7557): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7564): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7574): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7578): error C4668: '_WIN32_WINNT_WIN10_TH2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7583): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(7777): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12249): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12266): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12285): error C4668: '_WIN32_WINNT_WIN10_RS2' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  C:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um\winioctl.h(12404): error C4668: '_WIN32_WINNT_WIN10_RS3' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'

I’ve seen that people have had similar problems before when upgrading from 4.19 to 4.20, but this is not the case for me and none of the existing solutions resolve the issue

Yea, don’t add Standard Lib includes. It’s asking for trouble.UE overloads quite a few Macros / defines that those includes tend to use.

You likely need to rebuild your solution to clean out any generated headers that copied over that include statement. You can also regenerate your solution just to be really safe (right click on your UProject file -> Generate Visual Studio Solution).

Hm. I’ve rebuilt and generated VS solution, but the problem still persists. Other options?

Search for “Binaries” in your project folder and delete every Binaries folder you find. Then re-generate the project again, then load it and just check to see if it all makes sense - e.g. no odd includes, it’s only trying to build the main project, etc.

Then quit VS and load your uproject file instead and let UE handle the entire build. If that fails grab the log file it output.

So I did that. The project file can’t be opened directly anymore. I get a popup message saying that there are missing modules. If I try to rebuild them, I get a “compile failed” message. Building from VS still produces the exact same errors.

The “no odd includes” was the solution for me - my IDE automatically added one ios related include, which led to the compilation errors. Thanks!

Thanks for the hint @Zcience ! Somehow my IDE added #include <activation.h> into a cpp where I had added a constructor. After removing this, I could at least get a clean build.

2 Likes

I suddenly face this problem when I try to migrate my project UE4.27 to the just released UE5. Unfortunately my project integrates a piece of SQLite source code, so it certainly have many “odd includes” from standard library. Really desperate…

As Maciek_Leto said - check for weird includes.
Based on that advice I TRIED to do a find '#include <' on my source files, but found nothing.
When I inspected them manually however, I found a dirty little
#include <shlobj_core.h> had somehow gotten into one of the headers (rider greys out includes that are not actually being used - which made it hard to see)

I deleted that, and everything compiles again.

(I have to say, this is not the first time Rider has caused problems like this for me - it loves to go pasting #includes that you dont actually want. wish it needed confirmation for this.)

2 Likes

winioctl.h(10326): [C4668] ‘_WIN32_WINNT_WIN10_TH2’ is not defined as a preprocessor macro, replacing with ‘0’ for ‘#if/#elif’

Hello, same error happened to me. I was coding as normal when suddenly “Rider” kind of hanged for 5 seconds and then loaded some very long variable name, I deleted it and after that my code didn’t compile, a few hours later, I found that Rider auto included the following header:

#include <Windows.ApplicationModel.Calls.h>

2022-05-27T00:28:00Z

2 Likes

I had the same problem, rider auto included some header. Thanks

SOLVED! Added the Macro Definitions in the Build.CS file:
PublicDefinitions.AddRange(
new string[]
{
“_WIN32_WINNT_WIN10_TH2”,
“_WIN32_WINNT_WIN10_RS1”,
“_WIN32_WINNT_WIN10_RS2”,
“_WIN32_WINNT_WIN10_RS3”,
“_WIN32_WINNT_WIN10_RS4”,
“_WIN32_WINNT_WIN10_RS5”
}
);

3 Likes

yep happened for me as well. Didn’t noticed the last time I ran the game … wasn’t probably not fully recompiled. A weird include sneaked its way in my code. I just searched all my source files for ‘#include’ and reviewed all of them.
Probably faster is to check your last check-in, if you have one.

is this what we have to do now?

can you PLEASE explain what you mean by a weird include code sneaked its way into your code?

How did something like this happen? Others are having code in places it shouldn’t be, and some peoples EOS stopped working… my deviceID doesnt work anymore

can someone leave step by step directions on how to fix this?