How to #include windows.h?

I have seen the solutions in this link and also in this link. However I could not solve the problem.

I simply want to include windows.h and I use the following:

  • LARGE_INTEGER (in header file)
  • QueryPerformanceFrequency (in cpp file)
  • QueryPerformanceCounter (in cpp file)

So I can’t use this in the cpp file (I need the include in header file):

#include "AllowWindowsPlatformTypes.h"

#include windows.h

#include "HideWindowsPlatformTypes.h"

When I include it like this in header file it still gives me the Error 1 error C2872: 'DWORD' : ambiguous symbol C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\concrt.h 5248. error.

Edit: I have also seen an include windows.h in the .rc file of the project. So it’s displaying the above error twice.

Thanks in advance.

1 Like

You should avoid using system call for portability reasons and reflection system of UE4.limitations, it only supports types inside UE4 and you can’t use it with UPROPERTY and things like that. UE4 is wrapping most system APIs in to it’s own standard library and using it give you 100% sure that your code will build on any platform and any compiler that UE4 supports. So you should find equivlents, for example UE4 got it’s own implementation for big integer called TBigInt

I can’t find alternative for function you want to use but on search in engine source code, those functions are used in PlatfromTime

https://github.com/EpicGames/UnrealEngine/blob/c9f4efe690de8b3b72a11223865c623ca0ee7086/Engine/Source/Runtime/Core/Private/Windows/WindowsPlatformTime.cpp#L12

So if you search for pecision or something, UE4 already use it in it’s timer codes

But if you want to use those badly i find that engine includes Windows.h with this include you could try it

#include "Windows/WindowsSystemIncludes.h"