Mac build error in superclass array initializer in mrml volume rendering properties

When I build now on mac I get the error below (related to this recent commit about volume rendering presets).

/Users/pieper/slicer4/latest/Slicer/Modules/Loadable/VolumeRendering/MRML/vtkMRMLVolumePropertyNode.cxx:27:19: error: expected '('
  , EffectiveRange{0.0, -1.0}
                  ^
more of the build errors
/Users/pieper/slicer4/latest/Slicer/Modules/Loadable/VolumeRendering/MRML/vtkMRMLVolumePropertyNode.cxx:27:20: warning: expression result unused [-Wunused-value]
  , EffectiveRange{0.0, -1.0}
                   ^~~
/Users/pieper/slicer4/latest/Slicer/Modules/Loadable/VolumeRendering/MRML/vtkMRMLVolumePropertyNode.cxx:27:29: error: expected ';' after expression
  , EffectiveRange{0.0, -1.0}
                            ^
                            ;
/Users/pieper/slicer4/latest/Slicer/Modules/Loadable/VolumeRendering/MRML/vtkMRMLVolumePropertyNode.cxx:27:25: warning: expression result unused [-Wunused-value]
  , EffectiveRange{0.0, -1.0}
                        ^~~~
/Users/pieper/slicer4/latest/Slicer/Modules/Loadable/VolumeRendering/MRML/vtkMRMLVolumePropertyNode.cxx:28:3: error: expected unqualified-id
  , DisabledModify(0)
  ^
2 warnings and 3 errors generated.

I can work around it with this patch but I wonder if there’s a better solution:

 vtkMRMLVolumePropertyNode::vtkMRMLVolumePropertyNode()
   : VolumeProperty(NULL)
-  , EffectiveRange{0.0, -1.0}
   , DisabledModify(0)
 {
+  this->EffectiveRange[0] = 0.0;
+  this->EffectiveRange[1] = -1.0;

This error doesn’t happen on the dashboard machine, maybe because it uses a custom compiler. I do not get the build error on linux.

I’m using the standard Xcode clang on mac. Does anyone else have the same problem?

Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I can build on my Mac - 10.12.6, my compiler:

~/Development/slicer/Slicer:7> llvm-gcc --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Update: This error only occurs on a Qt4 build (Qt5 build on same machine works) so this is a C++ 11 issue.

After talking with @pieper, his build was done against Qt4. This explains the error because in that case, C++98 was used.

Until Slicer 5 is out, I suggest we keep the code base compatible with both.

1 Like

I’m planning to fix it like this, so we’ll remember to fix it when we switch to C++11 only.

//----------------------------------------------------------------------------
vtkMRMLVolumePropertyNode::vtkMRMLVolumePropertyNode()
  : VolumeProperty(NULL)
#if __cplusplus >= 201103L
  , EffectiveRange{0.0,-1.0}
#endif
  , DisabledModify(0)
{
#if __cplusplus < 201103L
  this->EffectiveRange[0] = 0.0;
  this->EffectiveRange[1] = -1.0;
#endif

Confirmed it builds in both modes and committed as r27027.

1 Like