Compile error: '__faststorefence': is not a member of 'FWindowsPlatformMisc'

I get below compile error in DebugGame but not in DebugGame_Editor. There is no other information so any insights would be appreciated.

2>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Core\Public\Async/AsyncFileHandle.h(101): error C2039: '__faststorefence': is not a member of 'FWindowsPlatformMisc'
2>  c:\program files\epic games\ue_4.16\engine\source\runtime\core\public\Windows/WindowsPlatformMisc.h(35): note: see declaration of 'FWindowsPlatformMisc'
2>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Core\Public\Async/AsyncFileHandle.h(151): error C2039: '__faststorefence': is not a member of 'FWindowsPlatformMisc'
2>  c:\program files\epic games\ue_4.16\engine\source\runtime\core\public\Windows/WindowsPlatformMisc.h(35): note: see declaration of 'FWindowsPlatformMisc'
2>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Core\Public\Async/AsyncFileHandle.h(156): error C2039: '__faststorefence': is not a member of 'FWindowsPlatformMisc'
2>  c:\program files\epic games\ue_4.16\engine\source\runtime\core\public\Windows/WindowsPlatformMisc.h(35): note: see declaration of 'FWindowsPlatformMisc'
2>C:\Program Files\Epic Games\UE_4.16\Engine\Source\Runtime\Core\Public\Async/AsyncFileHandle.h(162): error C2039: '__faststorefence': is not a member of 'FWindowsPlatformMisc'
2>  c:\program files\epic games\ue_4.16\engine\source\runtime\core\public\Windows/WindowsPlatformMisc.h(35): note: see declaration of 'FWindowsPlatformMisc'

Any responses? This is coming from engine source and likely a bug…

Your code had include “windows.h” in the beginning of the .h file ? I have the same problems, just put “windows.h” after UE header files, or move “windows.h” from common .h file. By this,I solve this problem.

Your code had include “windows.h” in the beginning of the .h file ? I have the same problems, just put “windows.h” after UE header files, or move “windows.h” from common .h file. By this,I solve this problem.

At this topic

I found a solution for plugin coding: changing Plugin type from Runtime to Developer.

I know I’m necro-ing an old thread here but the existing answers on this aren’t exactly correct.

What’s going on here is the windows.h include is defining one or more types that conflict with later definitions within unreal.
You can fix this by surrounding it with PreWindowsApi.h and PostWindowsApi.h includes that define things Windows will expect, and then undefine things that will conflict with Unreal:

#if PLATFORM_WINDOWS
THIRD_PARTY_INCLUDES_START
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"

#include Windows.h

#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
THIRD_PARTY_INCLUDES_END
#endif

This will ensure that things are set up correctly for the Windows include, and then properly cleaned up to allow Unreal to get on with its work.

Let’s say, however, that the Windows.h include is inside another library that you can’t easily change - you can wrap it something like this:

#if PLATFORM_WINDOWS
// Foo libraries include Windows headers. Use these includes and the end includes below to ensure that windows header includes don't conflict with Unreal definitions.
THIRD_PARTY_INCLUDES_START
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"
#endif

#include "FooLibrary/Foo.h"
#include "FooLibrary/Bar.h"

#if PLATFORM_WINDOWS
#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
THIRD_PARTY_INCLUDES_END
#endif
3 Likes

I can’t believe how solid of an answer this is. Thank you!

Thank you for this valuable nugget of information!