Does UE4 have compile-time constants?

I was wondering, is there any way to determine at compile time if we’re running in the UE4 editor, or in a packaged game? Is there some sort of compile-time constant defined by UE4’s build system like UE4_EDITOR so that I can write

#ifdef UE4_EDITOR
    do_stuff();
#endif

Yup…

#if WITH_EDITOR
 do_stuff();
#endif

#if WITH_EDITORONLY_DATA
  do_stuff();
#endif

Difference between WITH_EDITOR and WITH_EDITORONLY_DATA is this:

WITH_EDITOR: used to exclude complete functions (declaration and definition) in packaged games. Mostly used for EDITOR functions which cause compile errors in packaged game where you dont have editor module :slight_smile:

WITH_EDITORONLY_DATA: used to mark things inside the scope and inside the function (you cant exclude complete functions, but you can exclude different things inside the function)

for example:

.h

#if WITH_EDITOR
void EditorFunction();
#endif

.cpp

#if WITH_EDITOR
void Class::EditorFunction()
{
     // do something
}
#endif

2.

void Class::BeginPlay()
{
     int32 i = 0;

#if WITH_EDITORONLY_DATA
     i = 1; // be one while we using editor
#endif
}

EDIT: This does not work. WITH_EDITORDATA_ONLY seemed to be defined regardless of whether or not I was using the UE4 editor.