After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 754863 - Fix build of example_glarea.cc
Fix build of example_glarea.cc
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
3.17.x
Other Windows
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2015-09-11 03:25 UTC by Fan, Chun-wei
Modified: 2015-09-17 08:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix build of example_glarea.cc (1.34 KB, patch)
2015-09-11 03:27 UTC, Fan, Chun-wei
accepted-commit_now Details | Review
Fix build of example_glarea.cc (on Visual Studio) (1.46 KB, patch)
2015-09-14 03:12 UTC, Fan, Chun-wei
none Details | Review

Description Fan, Chun-wei 2015-09-11 03:25:47 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!
Comment 1 Fan, Chun-wei 2015-09-11 03:27:06 UTC
Created attachment 311108 [details] [review]
Fix build of example_glarea.cc

.
Comment 2 Kjell Ahlstedt 2015-09-12 09:54:10 UTC
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.
Comment 3 Fan, Chun-wei 2015-09-14 03:12:34 UTC
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!
Comment 4 Kjell Ahlstedt 2015-09-14 08:18:44 UTC
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.
Comment 5 Fan, Chun-wei 2015-09-17 08:04:10 UTC
Hi Kjell,

I pushed the vector method as you suggested as 1ee68b6.

With blessings, thank you!