Adding code to project in the editor breaks the whole project

Hello!

I added a couple of new classes to a project in the editor using Add Code To Project. After that, Visual Studio gives the errors below.

Even removing the new classes and all my other source code files from the project does not fix it. And the project compiled fine before adding the classes, so the error is not in my code.

And this has happened twice now on different projects.

I’m using UE 4.5.1 and Visual Studio Express 2013 for Windows Desktop.

Thanks for any help!

Visual Studio output:

1>------ Build started: Project: GameProto, Configuration: Development_Editor x64 ------
1>  Performing 10 actions (4 in parallel)
1>  PCH.GameProto.GameProto.h.cpp
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(10): error C2079: 'FComponentInstanceDataBase' uses undefined class 'DLLIMPORT'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(11): error C2143: syntax error : missing '}' before 'public'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(11): error C2143: syntax error : missing ';' before 'public'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(11): error C2059: syntax error : 'public'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(13): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(13): error C2365: 'FComponentInstanceDataBase' : redefinition; previous definition was 'data variable'
1>          h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(10) : see declaration of 'FComponentInstanceDataBase'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(14): error C2550: 'FComponentInstanceDataBase' : constructor initializer lists are only allowed on constructor definitions
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(14): warning C4508: 'FComponentInstanceDataBase' : function should return a value; 'void' return type assumed
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(16): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(16): error C2365: 'FComponentInstanceDataBase' : redefinition; previous definition was 'data variable'
1>          h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(10) : see declaration of 'FComponentInstanceDataBase'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(18): error C2588: '::~FComponentInstanceDataBase' : illegal global destructor
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(19): error C2575: 'FComponentInstanceDataBase' : only member functions and bases can be virtual
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(19): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(19): error C2365: 'FComponentInstanceDataBase' : redefinition; previous definition was 'data variable'
1>          h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(10) : see declaration of 'FComponentInstanceDataBase'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(19): warning C4508: 'FComponentInstanceDataBase' : function should return a value; 'void' return type assumed
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(21): error C2270: 'MatchesComponent' : modifiers not allowed on nonmember functions
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(23): error C2059: syntax error : 'protected'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(25): error C2146: syntax error : missing ';' before identifier 'SourceComponentName'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(25): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(29): error C2146: syntax error : missing ';' before identifier 'SourceComponentTypeSerializedIndex'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(30): error C2059: syntax error : '}'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(30): error C2143: syntax error : missing ';' before '}'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(37): error C2079: 'FComponentInstanceDataCache' uses undefined class 'DLLIMPORT'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(38): error C2143: syntax error : missing '}' before 'public'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(38): error C2143: syntax error : missing ';' before 'public'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(38): error C2059: syntax error : 'public'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(39): error C2365: 'FComponentInstanceDataCache' : redefinition; previous definition was 'data variable'
1>          h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(37) : see declaration of 'FComponentInstanceDataCache'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(39): warning C4508: 'FComponentInstanceDataCache' : function should return a value; 'void' return type assumed
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(42): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(42): error C2365: 'FComponentInstanceDataCache' : redefinition; previous definition was 'data variable'
1>          h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(37) : see declaration of 'FComponentInstanceDataCache'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(45): error C2065: 'TSharedPtr' : undeclared identifier
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(45): error C2065: 'NewData' : undeclared identifier
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(45): error C2182: 'AddInstanceData' : illegal use of type 'void'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(48): error C2270: 'ApplyToActor' : modifiers not allowed on nonmember functions
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(50): error C2270: 'HasInstanceData' : modifiers not allowed on nonmember functions
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(50): error C2065: 'TypeToDataMap' : undeclared identifier
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(50): error C2228: left of '.Num' must have class/struct/union
1>          type is 'unknown-type'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(52): error C2059: syntax error : 'private'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(54): error C2143: syntax error : missing ';' before '<'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(54): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(55): error C2059: syntax error : '}'
1>h:\program files\epic games\4.5\engine\source\runtime\engine\public\ComponentInstanceDataCache.h(55): error C2143: syntax error : missing ';' before '}'
1>H:\Program Files\Epic Games\4.5\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h(10): fatal error C1189: #error :  "STATS must be defined as either zero or one."
1>  -------- End Detailed Actions Stats -----------------------------------------------------------
1>ERROR : UBT error : Failed to produce item: H:\Unreal Projects\GameProto\Binaries\Win64\UE4Editor-GameProto.pdb
1>  Cumulative action seconds (8 processors): 0,00 building projects, 0,10 compiling, 0,00 creating app bundles, 0,00 generating debug info, 0,00 linking, 0,00 other
1>  UBT execution time: 4,01 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""H:\Program Files\Epic Games\4.5\Engine\Build\BatchFiles\Build.bat" GameProtoEditor Win64 Development "H:\Unreal Projects\GameProto\GameProto.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

In case anyone has similar errors, I had a source file called “Platform.h” which was conflicting with the engine file “Platform.h”. And the project broke at random point. And apparently removing the file from the solution explorer did not fix my problem because the file was not actually deleted.

Hi JaakkoAssola,

I apologize for the trouble that you experienced. Ideally if you try to name a new class with the same name as an existing class, you should receiving a warning or not be allowed to do it at all. I have entered a report about this to see if we might be able to improve on this process (UE-4770).

With regards to your attempts to remove the class files, you would need to close Visual Studio and delete the files using your Windows Explorer, then right-click on your .uproject file and select Generate Visual Studio project files. When you open the solution again in Visual Studio, the files for that class will no longer be included.

Are there any other potential causes for this exact error? I wasn’t warned of any files that might override the base.

I have a relatively simple plugin file-wise and yes, there appeared to be a Utils.h file, so I renamed it and renamed the couple of include lines that referenced it. However the error still exists.

[2015.07.23-04.43.17:729][  0]--------------------Project: Default-------------------------------------------
[2015.07.23-04.43.17:729][  0] (0:00.20 at +0:00)
[2015.07.23-04.43.17:729][  0]PluginGeneratedActor.cpp
[2015.07.23-04.43.17:729][  0]C:\UnrealEngine\UEOctane\Engine\Source\Runtime\Engine\Public\ComponentInstanceDataCache.h(17) : error C2079: 'FActorComponentInstanceData' uses undefined class 'DLLIMPORT'
[2015.07.23-04.43.17:729][  0]C:\UnrealEngine\UEOctane\Engine\Source\Runtime\Engine\Public\ComponentInstanceDataCache.h(18) : error C2143: syntax error : missing '}' before 'public'
[2015.07.23-04.43.17:729][  0]C:\UnrealEngine\UEOctane\Engine\Source\Runtime\Engine\Public\ComponentInstanceDataCache.h(18) : error C2143: syntax error : missing ';' before 'public'
[2015.07.23-04.43.17:729][  0]C:\UnrealEngine\UEOctane\Engine\Source\Runtime\Engine\Public\ComponentInstanceDataCache.h(18) : error C2059: syntax error : 'public'
[2015.07.23-04.43.17:730][  0]C:\UnrealEngine\UEOctane\Engine\Source\Runtime\Engine\Public\ComponentInstanceDataCache.h(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
[2015.07.23-04.43.17:731][  0]C:\UnrealEngine\UEOctane\Engine\Source\Runtime\Engine\Public\ComponentInstanceDataCache.h(20) : error C2365: 'FActorComponentInstanceData' : redefinition; previous definition was 'data variable'

Hi Antidamage,

Did you run Generate Project Files after renaming the file? If so, did the error persist after doing so?

Tim