# Using #ifdef doesn't work with Unreal Header Tool

**URL:** <https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377>\
**Category:** C++\
**Tags:** uht, unreal-engine, question, CPP\
**Created:** [August 7, 2016, 12:46pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377 "2016-08-07T12:46:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PersonGUy223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PersonGUy223](https://forums.unrealengine.com/u/PersonGUy223)\
**Post date:** [August 7, 2016, 12:46pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/1 "2016-08-07T12:46:20Z")

</div>

I’ve got some struct definitions for both C and C++ in one header, and using #if defined \_\_cplusplus doesn’t seem to work with the unreal header tool.

My code looks like this:

```
   // Atmos.h
    #if defined __cplusplus || UE_GAME || UE_EDITOR || UE_SERVER
    #pragma once
    #include "Atmos.generated.h"
    
    USTRUCT(Blueprintable)
    struct FGases
    {
    	GENERATED_BODY()
    	...
    };
    
    USTRUCT()
    struct FAtmosVoxel
    {
    	GENERATED_BODY()
    	...
    };
    
    #else
    
    typedef struct
    {
    	...
    } AtmosVoxel;
    
    #endif

```

and trying to include it produces an error that the C++ structs are not USTRUCT types. When I comment out the preprocessor directives it works fine.

Do #ifdefs not work for the unreal header tool or am I doing something wrong? I read in another question that they were fixed

---

<div class="post-metadata">

**Author:** ![DennyR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DennyR](https://forums.unrealengine.com/u/DennyR)\
**Post date:** [August 7, 2016, 4:10pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/2 "2016-08-07T16:10:44Z")

</div>

According to [this answerhub post](https://answers.unrealengine.com/questions/34368/can-unreadheadertool-handle-ifdef.html), it should work. Never used it in Unreal though, so I can’t tell.

You might have another bug in your code though.  
You are using `USTRUCT(Blueprintable)` what you want is `USTRUCT(BlueprintType)` though.

Blueprintable exposes a class to BP allows subclassing of it. Unreal does not support subclasses of UStructs in BP (or anywhere for that matter).

---

<div class="post-metadata">

**Author:** ![PersonGUy223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PersonGUy223](https://forums.unrealengine.com/u/PersonGUy223)\
**Post date:** [August 7, 2016, 8:21pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/3 "2016-08-07T20:21:00Z")

</div>

That didn’t fix it

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_86746194](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_86746194](https://forums.unrealengine.com/u/anonymous_user_86746194)\
**Post date:** [August 8, 2016, 3:03am UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/4 "2016-08-08T03:03:55Z")

</div>

You don’t need the defined keyword. If it is not defined it is falsy.

You are doing the equivalent of this in the macro world:

```
if (I < 5 || 10 || 17)

```

This is an illegal statement. The code you want is:

```
#if __cplusplus || UE_GAME || UE_EDITOR || UE_SERVER

```

---

<div class="post-metadata">

**Author:** ![PersonGUy223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PersonGUy223](https://forums.unrealengine.com/u/PersonGUy223)\
**Post date:** [August 8, 2016, 12:33pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/5 "2016-08-08T12:33:54Z")

</div>

That didn’t fix it

---

<div class="post-metadata">

**Author:** ![trojanfoe](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/trojanfoe/32/88719_2.png) [@trojanfoe](https://forums.unrealengine.com/u/trojanfoe)\
**Post date:** [August 8, 2016, 12:54pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/6 "2016-08-08T12:54:23Z")

</div>

Isn’t `__cplusplus` always defined, so that’s the equivalent of `#if 1`. What is this `#if` statement supposed to do?

---

<div class="post-metadata">

**Author:** ![PersonGUy223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PersonGUy223](https://forums.unrealengine.com/u/PersonGUy223)\
**Post date:** [August 8, 2016, 12:59pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/7 "2016-08-08T12:59:26Z")

</div>

I’m including this header in OpenCL C, I want to place both struct types in one file for convenience

---

<div class="post-metadata">

**Author:** ![PersonGUy223](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PersonGUy223](https://forums.unrealengine.com/u/PersonGUy223)\
**Post date:** [August 8, 2016, 9:22pm UTC](https://forums.unrealengine.com/t/using-ifdef-doesnt-work-with-unreal-header-tool/366377/8 "2016-08-08T21:22:49Z")

</div>

I looked through the Header Tool source and it looks like it doesn’t parse any if/ifdefs for C++, so I just wrote a BlueprintType wrapper struct in another file for the C/C++ struct
