I tried using the CActorFramework library together with ue4 and encountered some problems. CAF is making use of anonymous unions with template datatypes which may be classes who needs to be constructed. For example:
template<T>
class MyClass {
union {
T data;
}
}
In which case T resolves to another class who needs a call to its constructor. So the constructor needs to be manually called.
This is perfectly valid code according to the c++ standard and compiles without problems in a test project without any other code. If however i try to do this within a ue4 project the msvc compiler throws an “error C4582 constructor is not implicitly called” and “error C4583 destructor is not implicitly called” error.
I suspect this is due to some ue4 setting, but i sadly have no clue where to start. Any ideas on how to solve this would be appreciated.
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 usable.
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.
Yeah, thanks for leaving that here. I got frustrated and asked another similiar question which got me to the same conclusion. I solved it by manually disabling the warnings before including and reenabling them after including the critical headers that created problems. Like that you’re not required to edit engine code, but it’s more work since you have to do it for every affected header, or capsule them in one big header.