# \#define doesn't work with UFUNCTIONS

**URL:** <https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802>\
**Category:** Blueprint\
**Tags:** unreal-engine, bug-report, editor, Blueprint, CPP, question\
**Created:** [March 7, 2016, 12:47pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802 "2016-03-07T12:47:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mateusz.Wiech](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mateusz.Wiech](https://forums.unrealengine.com/u/Mateusz.Wiech)\
**Post date:** [March 7, 2016, 12:47pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/1 "2016-03-07T12:47:31Z")

</div>

Hi,

I tried to make use of #define with UFUNCTIONS today and it seems this is not working properly. I want to remove blueprint calls for my functions on demand to use of #define is probably the best approach to make this by changing only one variable in code.

Unfortunately, when I’m adding #if #endif for the UFUNCTION macro or full function definition, it is no longer available in blueprint no matter what.

I believe it shouldn’t work that way or maybe I’m doing something wrong?

To reproduce the issue:

1. Create simple c++ project
2. Add custom class based on StaticMeshActor
3. Create blueprint callable function in our actor
4. Check if you function is accessible in the blueprint
5. Add your #define and surround your function with #if/#endif

Any help with this issue would be appreciated.

---

<div class="post-metadata">

**Author:** ![MiKom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MiKom](https://forums.unrealengine.com/u/MiKom)\
**Post date:** [March 7, 2016, 1:31pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/2 "2016-03-07T13:31:27Z")

</div>

UnrealHeaderTool that generates reflection information runs before C++ preprocessor. UHT simply assumes that every #if statement evaluates to false and generates no reflection info for these functions.

If you want these functions to do nothing on certain builds, you’d have to put the #if statements inside the functions bodies:

```
float AMyActor::MyBPFunction()
{
#if COMPILE_TIME_CONDITION
    /* code when turned on */
    return SomeValue;
#else
    return 0.0f;
#endif
}
```

---

<div class="post-metadata">

**Author:** ![Mateusz.Wiech](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mateusz.Wiech](https://forums.unrealengine.com/u/Mateusz.Wiech)\
**Post date:** [March 7, 2016, 2:00pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/3 "2016-03-07T14:00:28Z")

</div>

Thanks for the response. This doesn’t fix my issue, because functions will be still visible in blueprints but simply won’t work. But as far as I understand, there is no fix to this so I need to accept UnrealHeaderTool limitations 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [March 7, 2016, 3:55pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/4 "2016-03-07T15:55:32Z")

</div>

Hello ,

What type of condition are you using for your #if statements? It could be failing the condition so that is why I’m curious. When following your repro steps, I used #if WITH\_EDITOR which will result in true unless you’re working with a standalone / packaged game.

---

<div class="post-metadata">

**Author:** ![Mateusz.Wiech](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mateusz.Wiech](https://forums.unrealengine.com/u/Mateusz.Wiech)\
**Post date:** [March 8, 2016, 9:35am UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/5 "2016-03-08T09:35:21Z")

</div>

Hi ,

I’m using custom #define WITH\_MY\_CUSTOM\_DEFINE 1. #if and #endif statements are in the same file so there is no possibility of the mistake.

![81362-screen.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/e/4ae788cedba49428384eef0fc7bad9ff7251837d.png)

I assume that WITH\_EDITOR works because it is defined by UBT. Information about this is in Build.h.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [March 9, 2016, 2:58pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/6 "2016-03-09T14:58:41Z")

</div>

Ah I see, thank you for clarifying that. I’m not familiar with using the custom #defines myself so I wasn’t quite understanding you. I see the issue now however and I’ve placed a bug in for the issue. For reference, the bug’s number is UE-28103. I’ll be sure to let you know if any changes are made to it in the future. Unfortunately, I can’t think of any workarounds for the problem at the moment besides using existing specifiers.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [March 14, 2016, 1:33pm UTC](https://forums.unrealengine.com/t/define-doesnt-work-with-ufunctions/349802/7 "2016-03-14T13:33:07Z")

</div>

Hello .

After putting in this bug report, I’ve been given the information that this is a known limitation of UHT. Nothing that is inside of an #ifdef except WITH\_EDITOR or WITH\_EDITORONLY\_DATA will be parsed by UHT. Unfortunately, this is something that you will have to work with.
