I have no idea what’s happening anymore. I’ve tried everything I can think of with no luck. I have been trying to add a new class to my existing project but every time I try to compile it in visual studio, I get 100+ compiler errors which have nothing to do with the class I just added.
Environment:
Visual Studio Community Edition 2013
Engine: UE 4.6.1
Source control: Perforce
OS: 64 bit
Control Scenario 1: I compile my project with my existing classes.
Result: Everything compiles successfully and the editor opens.
Scenario 2: I add a brand new header file and do not declare anything.
Result: Everything compiles successfully and the editor opens
Scenario 3: I create a bare essentials CPP file to go with the header file.
Result: The compile fails. There are no errors in my code. One of my other classes is now unrecognized and that’s causing 100+ errors (not linker errors).
Removing the newly added CPP file causes the errors to go away, so there’s some sort of relationship going on here.
Scenario 4: I just create a new blank CPP file with no header file. The only line it has: #include “[projectname].h”
Result: Same as scenario #3.
Scenario 5: I create a brand new project and add a new header and CPP file, just like I do in Scenario 3 &4
Result: Compiles with no issues. Therefore, its project specific.
I tried adding the class through both the editor and manually through visual studio. Both cause the same results.
What I’ve tried:
- I looked at the [ProjectName].generated.cpp file between scenario 1 and scenario 3 and ran WinDiff against them
to see if there was anything usual in the generated code, but nothing stood out as looking usually out of place. - I completely clean the project and rebuild it. No change.
- I completely delete all generated files and OBJ files. No change.
- I’ve tried to create classes with different names and inheriting from different objects. No change.
I’ve added dozens of sources files to the project in the past and none of those have caused any issues. It seems that this started happening recently after I submitted my last build to source control. I tried checking out all of my files just in case there was some write protection issues, but that made no change.
Why would my code compile with no issues, but adding a blank CPP file to the project causes it to break? All I can think is that somewhere, the generated code is getting messed up by a new CPP file and I don’t know where its happening or how to fix it.
Header file: “TestClass.h”
#pragma once
#include "TestClass.generated.h"
UCLASS()
class ATestClass : public AActor
{
GENERATED_BODY()
public:
};
CPP File: “AnyName.cpp”
#include "MageMaster2.h"