# Issue with macro redefinition

**URL:** <https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [March 20, 2018, 1:29pm UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234 "2018-03-20T13:29:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_07ba773b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_07ba773b](https://forums.unrealengine.com/u/anonymous_user_07ba773b)\
**Post date:** [March 20, 2018, 1:29pm UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/1 "2018-03-20T13:29:21Z")

</div>

I’m including in my project some external content, which seems to also end up including a file called ‘ **winnt.h** ’, which is part of Windows (it’s contained in \*\*C:\Program Files (x86)\Windows Kits\8.1\include\um\*\*).

The problem is that this header file contains a definition for a macro that UE4 uses: TEXT

```auto

#define TEXT(quote) __TEXT(quote) // r_winnt

```

My project still builds, but I can see this causing problems, as it throws up these lines in the output of Visual Studio:

```auto

2>C:\Program Files (x86)\Windows Kits\8.1\include\um\winnt.h(536): warning C4005: 'TEXT': macro redefinition
2>c:\program files\epic games\ue_4.18\engine\source\runtime\core\public\HAL/Platform.h(848): note: see previous definition of 'TEXT'

```

Anyone know anything I can do to avoid conflicts with this redefinition of a macro?

---

<div class="post-metadata">

**Author:** ![erebel55](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@erebel55](https://forums.unrealengine.com/u/erebel55)\
**Post date:** [November 29, 2018, 12:56am UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/2 "2018-11-29T00:56:25Z")

</div>

Did you ever figure out how to solve this?

Thank you

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_07ba773b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_07ba773b](https://forums.unrealengine.com/u/anonymous_user_07ba773b)\
**Post date:** [November 29, 2018, 9:35am UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/3 "2018-11-29T09:35:17Z")

</div>

I had this problem when I was trying to work out how to build and include the OpenVDB library in my UE4 project. Fortunately for me, around the same time Epic released the ProxyLOD plugin, which uses OpenVDB, so I was able to essentially steal their builds/includes of the libraries. I’m not sure how Epic themselves got around this problem though…

Sorry I can’t be more helpful.

---

<div class="post-metadata">

**Author:** ![DesertEagle\_PWN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DesertEagle\_PWN](https://forums.unrealengine.com/u/DesertEagle_PWN)\
**Post date:** [June 3, 2019, 5:58pm UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/4 "2019-06-03T17:58:42Z")

</div>

I’m also running into this issue trying to access windows specific functionality from within my Unreal Application using #include “Windows/MinWindows”. I’m running 4.22.1 and would still like a solution to this problem if anyone has figured it out.

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [June 4, 2019, 12:44am UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/5 "2019-06-04T00:44:00Z")

</div>

If you are doing WinSock TCP stuff you need a “header sandwich” to instruct Unreal to ignore all the Windows base stuff.

```auto

// put this at the top of your .h file above #includes
// UE4: 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
// UE4: disallow windows platform types
// this was enabled at the top of the file
#include "PostWindowsApi.h"
#include "HideWindowsPlatformTypes.h"

```

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [June 4, 2019, 12:45am UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/6 "2019-06-04T00:45:42Z")

</div>

If it helps the full top of our TCP class .h files look like this:

```auto

// UE4: allow Windows platform types to avoid naming collisions
// this must be undone at the bottom of this file!
#include "AllowWindowsPlatformTypes.h"
#include "prewindowsapi.h"

#include <exception>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <mutex>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <thread>

#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")

```

---

<div class="post-metadata">

**Author:** ![MeddleGearSalad](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/meddlegearsalad/32/88706_2.png) [@MeddleGearSalad](https://forums.unrealengine.com/u/MeddleGearSalad)\
**Post date:** [September 21, 2021, 6:38pm UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/7 "2021-09-21T18:38:37Z")

</div>

Yup, as usual would love some ■■■■■■■ useful info here

---

<div class="post-metadata">

**Author:** ![LR-Oeil2Taupe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LR-Oeil2Taupe](https://forums.unrealengine.com/u/LR-Oeil2Taupe)\
**Post date:** [February 11, 2022, 8:36am UTC](https://forums.unrealengine.com/t/issue-with-macro-redefinition/108234/8 "2022-02-11T08:36:42Z")

</div>

Hello here 🙂  
Sorry if my English is bad, isn’t my language native 🙂

Unreal use already this macro ‘TEXT’  
#ifdef UNICODE  
#define TEXT(quote) L##quote // wchar\_t  
#else  
#define TEXT(quote) quote // char  
#endif

But when us included a header windows ‘TEXT’ is already defined…  
#include “Winnt.h”

To avoid conflicts we need to delete the macro then redefine it as below:

… your code …

#ifdef TEXT  
#undef TEXT // Delete macro UE4  
#endif

#include “Winnt.h” // Define macro Win32

#ifdef TEXT  
#undef TEXT // Delete macro Win32  
#endif

#define TEXT(quote) \_\_ TEXT(quote) // Define macro UE4

… your code …

Secondary Windows macro ‘\_\_ TEXT’ like ‘TEXT’

I hope it helps you 😊
