x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

#define doesn't work with UFUNCTIONS

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.

Product Version: UE 4.10
Tags:
more ▼

asked Mar 07 '16 at 12:47 PM in Bug Reports

avatar image

Mateusz.Wiech
66 7 8 19

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Mar 09 '16 at 02:58 PM

avatar image Matthew J Mar 14 '16 at 01:33 PM

Hello Mateusz.Wiech.

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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
 }
more ▼

answered Mar 07 '16 at 01:31 PM

avatar image

MiKom
535 17 9 39

avatar image Mateusz.Wiech Mar 07 '16 at 02:00 PM

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 :)

avatar image Matthew J Mar 07 '16 at 03:55 PM

Hello Mateusz.Wiech,

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.

avatar image Mateusz.Wiech Mar 08 '16 at 09:35 AM

Hi Matthew,

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.

alt text

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

screen.png (14.0 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question