winnt.h(620): warning C4005: 'TEXT': macro redefinition and HAL/Platform.h(1085): note: see previous definition of 'TEXT'

C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winnt.h(620): warning C4005: ‘TEXT’: macro redefinition
UATHelper: Package Plugin Task (Windows): d:\ue_4.27\engine\source\runtime\core\public\HAL/Platform.h(1085): note: see previous definition of ‘TEXT’

I found an error when I try to package my custom plugin on 4.27.2. Anyone know please give an example of code or how I can fix this. My Project is in C++

Hello, have you found a solution to this problem?

If you are including Windows stuff you need a “header sandwich” to instruct Unreal to to prevent the macro/define collisions. Been using this over 5+ projects and works from Unreal 4.9 to 5.1:

// put this at the top of your .h file above #includes
// UE5: allow Windows platform types to avoid naming collisions
// must be undone at the bottom of this file!
#include "AllowWindowsPlatformTypes.h"
#include "prewindowsapi.h"

… your
… header
… file
… content

// put this at the bottom of the .h file
// UE5: disallow windows platform types
// this was enabled at the top of the file
#include "PostWindowsApi.h"
#include "HideWindowsPlatformTypes.h"

There’s a few old threads about this but added it here.