On windows platform unreal projects are compiled wtih “Treat warnings as errors” flags.
However.
Since visual studio community 2015 uipdate 2 microsoft compiler spews warnings when it encounters initializer list (warning c4868).
Since this behavior is a part of the language, triggering this warning in the first place is idiotic, and with “/WX” it escalates into error.
Additional problem is that in case of UE4 project this warning may appear at the first line of “ProjectName.generated.h”, for example:
...\BlightUE4.generated.cpp : error C4868: compiler may not enforce left-to-right evaluation order in braced initializer list
...epic games\4.12\engine\source\runtime\coreuobject\public\uobject\class.h(547): error C4868: compiler may not enforce left-to-right evaluation order in braced initializer list
...epic games\4.12\engine\source\runtime\coreuobject\public\uobject\class.h(886): error C4868: compiler may not enforce left-to-right evaluation order in braced initializer list
Which will lead you to TCppStructOpts::Construct() and
Without any indication of what the heck instantiated those in the first place, where, and how.
Please consider fixing this nonsense (microsoft compiler is not the one that should be used with “treat warnings as errors”), or at least consider de-escalating c4868 specifically back to a warning.
I haven’t bothered to upgrade to VS 2015 update 2 because of this (and other) errors.
Could someone please confirm update 2 is officially supported in 4.12? I have looked through the release notes of 4.11 & 4.12 but can’t find anything conclusive.
First, the warning is actually accurate; Microsoft is telling you that it cannot actually implement the language as defined.
Second, turning off a particular warning in compiler settings (or using pragmas) is annoying, but totally doable.
It’s totally worth it to turn off that particular warning for now, in order to still get warnings-are-errors, because warnings-are-errors is super valuable!
Except that warning escalates to error even when the program is doing exactly what you want.
Also that’s not what the message is saying.
Pragma warning disable did not appear to work with /WX, and compiler settings will be lost when UE4 regenerates the project, so you need to do that within the file, preferably on *.h or *.cpp level.
To turn off the warning, you first need to know WHERE the problem happens. In this case - compiler doesn’t tell you.
Unreal’s build architecture makes it very hard to pinpoint actual line where this particular warning happens. See, “ProjectName.h” includes all the headers in your project, meaning that the warning will occur in “ProjectName.generated.cpp”, and error message won’t have any mention of actual header where the problem happens.
When you use clang or gcc. Not when you use microsoft compiler. Stuff like this should be optional. ESPECIALLY for microsoft compiler.
Not sure if it is officially supported, but I was able to compile the project on update 2 after finally finding the offending initializer list in one of the hundred of headers. The compiler didn’t tell me which header had the problem. I’m not happy about compiler behavioru though. Or vc++ behavior.
I would really prefer official support for latest clang and qtcreator (instead of a wiki article).
The reason why I even run in this problem is because someone I worked with before couldn’t build one of my past projects and a programmer they asked for help couldn’t do it too.
This kind of behavior from a compiler is very bad, and any C++ beginner will with 100% certainty sink on it.
It says exactly that the compiler may not be able to enforce the ordering of initializers of values in the brace-initializer construct that the language demands.
More information here: Compiler Warning C4868 | Microsoft Learn