A sudden override problem in old perfectly working code!

Hi,
I have many areas in my old code that were perfectly compiled for literally more than a year.
After updating the source code to latest version in GitHub as I usually do, these areas of the code all became areas of compilation error. All with the same error C3668.
This is an error where an overriden function in the child class using Super::FunctionName() ends up not working. The text of the errors says “method with override specifier ‘override’ did not override any base class methods”.
This might have to do with the macro GENERATED_BODY(), but I am not sure.

Interestingly, all the functions are trying to override the same function of AActor, namely AActor::PostEditChangeProperty(FPropertyChangedEvent & PropertyChangedEvent).

Another error immediately related, C2039, even states that the function PostEditChangeProperty is not a member of AActor. The function might just have been removed from the source code. But I am not sure about that.

A third and final type of errors is E1696 stating “cannot open source file MyClassName.generated.h”

As I said all of these errors appeared without me touching the now erroneous code for more than a year. I didn’t change anything, literally just updated the source code from GitHub.

The problem was solved by adding the directive #if WITH_EDITOR.
Simply before the declaration (usually in .h) and before the definition (usually in .cpp) of each function add the clause:
#if WITH_EDITOR
then after the line(s) of declaration/definition add the clause #endif.

This is specifically because the member function here is present only if the AActor was compiled for the editor, not for game launch for instance.

This wasn’t a requirement in my code because I am compiling with the editor anyway, but after the source code update it became a requirement regardless, which makes things more consistent overall I think.

2 Likes