GNOME Bugzilla – Bug 754863
Fix build of example_glarea.cc
Last modified: 2015-09-17 08:04:10 UTC
Hi, Some compilers, such as Visual Studio, do not like class members being directly initialized in a class definition where there is a constructor defined for it, which would break the build of example_glarea.cc on those compilers. I will attach a simple patch shortly to fix this. With blessings, thank you!
Created attachment 311108 [details] [review] Fix build of example_glarea.cc .
Review of attachment 311108 [details] [review]: Ok, but I'd prefer initialization in a member initializer list, if possible. gcc 4.9.2 accepts both alternatives. Example_GLArea::Example_GLArea() : m_RotationAngles{0.0f, 0.0f, 0.0f} { ... } A few other members of class Example_GLArea are also initialized in the class declaration, but they are not arrays.
Created attachment 311250 [details] [review] Fix build of example_glarea.cc (on Visual Studio) Hi Kjell, Apparently after a bit more investigation this is another quirk in Visual Studio 2013's C++-11 support, so it is not enough just to do a member initializer list (one will face the same compiler error C2536). One needs to declare the array as std:array, and then the member initializer list needs to be like: Example_GLArea::Example_GLArea() : m_RotationAngles({0.0f, 0.0f, 0.0f}) { ... } Please let me know which way is more preferred (I will change the commit message to say things about Visual Studio 2013, though, as a result). With blessings, thank you!
gcc accepts that alternative, too. It's acceptable. To further complicate this small issue, there's yet another alternative that looks nice: std::vector<float> m_RotationAngles; Example_GLArea::Example_GLArea() : m_RotationAngles(N_AXIS, 0.0f) { ... } It doesn't even involve C++11. It's not really important which alternative you choose, as long the compilers accept it. If you have a preference for one of them, choose that one, else choose std::vector.
Hi Kjell, I pushed the vector method as you suggested as 1ee68b6. With blessings, thank you!