Unable to compile new actor classes

I got a (rather large) project to help out on the programming for it. The project as I received it has no custom classes and no visual studio files. I open up the project, go to add a new C++ class, and select “Actor”, name it something (I’ve tried the default name “MyActor” and other names), select “public”, and the create the class. The new class will not compile. The project came with an Intermediate folder, and removing that before I open it for the first time gives the same result.

The log (pretty much syntax errors from SomeActor.generated.h, the header, and the cpp file):

CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(14) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(15) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(16) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(27) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(38) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(51) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(62) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(63) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(64) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\SomeActor.generated.h(75) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public\SomeActor.h(8) : error C2059: syntax error: 'user-defined literal'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public\SomeActor.h(9) : error C2059: syntax error: 'public'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public\SomeActor.h(10) : error C2143: syntax error: missing ';' before '{'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public\SomeActor.h(10) : error C2447: '{': missing function header (old-style formal list?)
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(8) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(11) : error C2065: 'PrimaryActorTick': undeclared identifier
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(11) : error C2228: left of '.bCanEverTick' must have class/struct/union
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(11) : note: type is 'unknown-type'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(13) : error C4508: 'ASomeActor': function should return a value; 'void' return type assumed
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(16) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(18) : error C2653: 'Super': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(23) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Private\SomeActor.cpp(25) : error C2653: 'Super': is not a class or namespace name
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(14) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(15) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(16) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(27) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(38) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(51) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(62) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(63) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(64) : error C2007: #define syntax
CompilerResultsLog:Error: Error d:\documents\unreal projects\240x2\intermediate\build\win64\ue4editor\inc\automotivematerials2\SomeActor.generated.h(75) : error C2007: #define syntax
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public/SomeActor.h(8) : error C2059: syntax error: 'user-defined literal'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public/SomeActor.h(9) : error C2059: syntax error: 'public'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public/SomeActor.h(10) : error C2143: syntax error: missing ';' before '{'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Source\AutomotiveMaterials2\Public/SomeActor.h(10) : error C2447: '{': missing function header (old-style formal list?)
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(14) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2065: 'ASomeActor': undeclared identifier
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2923: 'TClassCompiledInDefer': 'ASomeActor' is not a valid template type argument for parameter 'TClass'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2514: 'TClassCompiledInDefer': class has no constructors
CompilerResultsLog:Error: Error d:\programs\epicgames\ue_4.15\engine\source\runtime\coreuobject\public\UObject/UObjectBase.h(300) : note: see declaration of 'TClassCompiledInDefer'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2065: 'StaticClassFlags': undeclared identifier
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C3861: 'StaticClassCastFlags': identifier not found
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C3861: 'StaticConfigName': identifier not found
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2440: 'type cast': cannot convert from 'void (__cdecl *)(const FObjectInitializer &)' to 'UClass::ClassConstructorType'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : note: None of the functions with this name in scope match the target type
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2440: 'type cast': cannot convert from 'UObject *(__cdecl *)(FVTableHelper &)' to 'UClass::ClassVTableHelperCtorCallerType'
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : note: None of the functions with this name in scope match the target type
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2065: 'AddReferencedObjects': undeclared identifier
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(17) : error C2065: 'StaticClass': undeclared identifier
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(27) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(27) : error C3861: 'StaticClass': identifier not found
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(36) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(36) : error C3861: 'StaticClass': identifier not found
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(54) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(54) : error C2065: 'StaticClass': undeclared identifier
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(55) : error C2653: 'ASomeActor': is not a class or namespace name
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(55) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(55) : error C2550: 'ASomeActor': constructor initializer lists are only allowed on constructor definitions
CompilerResultsLog:Error: Error D:\Documents\Unreal Projects\240x2\Intermediate\Build\Win64\UE4Editor\Inc\AutomotiveMaterials2\AutomotiveMaterials2.generated.cpp(55) : error C4508: 'ASomeActor': function should return a value; 'void' return type assumed
CompilerResultsLog: Info ERROR: UBT ERROR: Failed to produce item: D:\Documents\Unreal Projects\240x2\Binaries\Win64\UE4Editor-AutomotiveMaterials2.dll
CompilerResultsLog: Info Total build time: 37.32 seconds (Local executor: 0.00 seconds)
LogMainFrame: MainFrame: Module compiling took 37.578 seconds

Out of curiosity, what does your “SomeActor” class look like?

The default class that is generated.

SomeActor.h: https://gist.github.com/nug700/537559ea3ed1fa0658fadfce4bd88acc

SomeActor.cpp: https://gist.github.com/nug700/a81ffa941349ceaa7bae1673dffd87cd

And here’s the generated.h: https://gist.github.com/nug700/0fe571e1dd18d455bd72407b533f0a6e

Closing ue4 then clean + rebuild produces the same errors in visual studio.

The root folder has to be named the same as the project for everything to work correctly.

Ah man. Thanks! True. I had the same problem: a million errors because I had this:

c:\Users\xxxx\Documents\Unreal Projects\CppBlueprint\02-project-setup\Pong.uproject

c:\Users\xxxx\Documents\Unreal Projects\CppBlueprint\02-project-setup\Pong.sln

But that’s not going to work. Do:

c:\Users\xxxx\Documents\Unreal Projects\Pong\Pong.uproject

c:\Users\xxxx\Documents\Unreal Projects\Pong\Pong.sln

I was running into the same problem, I found that the root folder does not have to named the same as the project folder, but the root folder cannot start with a number as stated in this post: link text

Both of the examples in this thread have numbers at the beginning of their root folder. Figured I’d add to the answer here in case someone else runs into this post before the other one like I did.

1 Like

Thanks Jedber’s, your answer fixed it for me as well. I had issues opening the ue4 project after updating from source control (SVN), the first C++ scripts were just added to the project/main trunk.

The message “Could not compile, try manually” popped up. I attempted to rebuild the sln project in VS but the build failed each time, mostly throwing out the error C2007: #define syntax across multiple .h or .ccp files.

After trying various solutions this one worked for me, hopefully it will work for others as well.

My root folder was F:\Behalled Studios\002Server Work\002Personal Branch… I just had to remove the 002s :stuck_out_tongue: Cheers for the solution.

This is an old forum, but i thought i would add some insight.
Before a took a GameDev-break, I changed the folder names of my projects (dumb mistake by me). When i came back to continue my work, NOT A SINGLE ONE OF MY PROJECTS WOULD OPEN. I thought it was because i updated the engine to 4.25, or because I updated VScode. I tried a million thing.

if only i knew it was because a dumb mistake of not naming the folder of the project, the same name as the project itself.

LESSON LEARNED

Man, what an absurd bug. I’ve been dealing with this for a while now. Thank you for the post.