Download

[Hint] UFUNCTION() Causes compilation errors. How to solve.

So when you declare a class function, you can normally compile without actually defining the function. This is useful when you just want to get the class functions sorted before you actually start defining them.

Unfortunately, if you declare a function with the UFUNCTION() macro, this will cause compilation errors if the function isn’t defined. I’m not sure if this is a bug or by design, but it’s rather annoying.

So if you are not ready to define the actual functionality, just put the empty function in the .cpp file and leave empty and then the project will compile and you can go back to defining all the functions once you are ready.

Exmaple 1: Define empty function in .cpp file:


void MyClass::UndefinedFunction()
{
}

Example 2: Define empty function in .h file:



void UndefinedFunction(){}; //Be sure to remove curly braces when you define the function in .cpp file.