Problem with CActorFramework and UE4

Hey guys,

I’ve been trying to get the CActorFramework (CAF) to work with UE4 for large scale OpenWorld Simulations. Statically compiling the library on windows, linking and and including the necessary files all worked. =) Also creating stand alone projects for CAF alone works as well. My problem arises when i combine CAF and UE4.

What happens is that MSVC (2015) throws a “error C4582 constructor is not implicitly called” and “error C4583 destructor is not implicitly called” when trying to create a basic “caf::actor_system”. These errors generate whenever there is a union with a none-trivial data member. For example:



class MyClass {
    MyClass();
    ~MyClass();

    bool isConstructed = false;
    union {
        ClassType value;
    }
} 

In these cases MSVC apparently expects for the constructor or destructor of ClassType to be explicitly called. Which makes sense, why it is being called like so for the destructor: (analog for the constructor)



MyClass::~MyClass() {
    if(isConstructed)
        value.~ClassType();
} 

Under normal circumstances, this works, compiles and behaves as expected. However, when done within a UE4 Project the named compiler errors are thrown. I belive this must have something to do with the compiler flags/settings passed to MSVC by the UE4 Project, but I have no clue where to start or what setting could possibly be the reason for this.

Any other ideas why these errors get thrown would be great as well.

Thanks for the help.

I just stumbled upon the same error when I was trying to include <variant> and <optional>.

Turns out UE4 is manually specifying which warnings to treat as errors in “WindowsPlatformCompilerSetup.h” and thereby (intentionally or unintentionally) also activating those warnings. Two of these are C4582 and C4583, which usually aren’t enabled in MSVC (warning level 4). You have to turn on the “/Wall” flag to see them in normal MSVC projects, which (if you’ve tried it before) gives you a bajillion different warnings inside even the standard library headers and isn’t really feasible.

I feel these two warnings should be removed from the giant list of “#pragma warning (error: …)”, which is what I ended up doing with my source build of UE4. I’m not entirely sure how you would fix this with a launcher build of UE4.