[Insight-developers] compilation error when compiled with gnu++0x flag

Williams, Norman K norman-k-williams at uiowa.edu
Wed May 9 11:33:19 EDT 2012


This is a problem with VNL, and I don't know if they've fixed it, or when
ITK will upgrade.

The problem is this, and affects CLang as well: According to the C++
standard, you can only initialize integral types as static data members of
a class.  GCC supports that as an extension, unless you tell it to
actually enforce the standard, which is what you're asking it to do with
-std=gnu++0x.

In VNL, if CMake detects GCC as a compiler, it goes ahead and defines the
static float members in line in the class. Otherwise it declares them
separately in a C++ file.

What I wish is that they'd define these constants separately always.

I can't imagine what they think is gained by having them in-line, unless
it makes the compiler load a constant directly into a register instead of
from memory.  That would be a performance win, I guess, if you write code
that references these constants a lot in inner loop.

What's really maddening with Clang is that it claims to be GCC with
respect to preprocessor symbols. This means when you build ITK, you get a
couple of megabytes of warnings about vnl_math.h.

--
Kent Williams norman-k-williams at uiowa.edu






On 5/9/12 7:00 AM, "Arnaud Gelas" <arnaudgelas at gmail.com> wrote:

>Hi all,
>
>When doing cmake -DCMAKE_CXX_FLAGS=-std=gnu++0x /path/to/ITK && make
>-j8, I get compilation errors in vnl_math (see below).
>
>gcc version: 4.6.3
>cmake version: 2.8.7
>
>What would be the best way to fix these errors?
>
>Thanks,
>Arnaud
>
>---
>
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:87:27:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œe¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:88:31:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œlog2e¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:89:32:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œlog10e¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:90:29:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œln2¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:91:30:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œln10¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:92:28:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œpi¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:93:35:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œpi_over_2¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:94:35:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œpi_over_4¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:95:37:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œone_over_pi¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:96:37:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œtwo_over_pi¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:97:41:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œtwo_over_sqrtpi¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:98:42:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œone_over_sqrt2pi¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:99:31:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œsqrt2¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:100:33:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œsqrt1_2¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:101:31:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œeuler¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:104:29:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œeps¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:105:33:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œsqrteps¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:107:34:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œfloat_eps¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.h:108:38:
>error: Œconstexpr¹ needed for in-class initialization of static data
>member Œfloat_sqrteps¹ of non-integral type
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:84:24:
>error: Œconst double vnl_math::e¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:84:14:
>error: uninitialized const Œvnl_math::e¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:85:24:
>error: Œconst double vnl_math::log2e¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:85:14:
>error: uninitialized const Œvnl_math::log2e¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:86:24:
>error: Œconst double vnl_math::log10e¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:86:14:
>error: uninitialized const Œvnl_math::log10e¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:87:24:
>error: Œconst double vnl_math::ln2¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:87:14:
>error: uninitialized const Œvnl_math::ln2¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:88:24:
>error: Œconst double vnl_math::ln10¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:88:14:
>error: uninitialized const Œvnl_math::ln10¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:89:24:
>error: Œconst double vnl_math::pi¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:89:14:
>error: uninitialized const Œvnl_math::pi¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:90:24:
>error: Œconst double vnl_math::pi_over_2¹ is not a static member of
>Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:90:14:
>error: uninitialized const Œvnl_math::pi_over_2¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:91:24:
>error: Œconst double vnl_math::pi_over_4¹ is not a static member of
>Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:91:14:
>error: uninitialized const Œvnl_math::pi_over_4¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:92:24:
>error: Œconst double vnl_math::one_over_pi¹ is not a static member of
>Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:92:14:
>error: uninitialized const Œvnl_math::one_over_pi¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:93:24:
>error: Œconst double vnl_math::two_over_pi¹ is not a static member of
>Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:93:14:
>error: uninitialized const Œvnl_math::two_over_pi¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:94:24:
>error: Œconst double vnl_math::two_over_sqrtpi¹ is not a static member
>of Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:94:14:
>error: uninitialized const Œvnl_math::two_over_sqrtpi¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:95:24:
>error: Œconst double vnl_math::one_over_sqrt2pi¹ is not a static member
>of Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:95:14:
>error: uninitialized const Œvnl_math::one_over_sqrt2pi¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:96:24:
>error: Œconst double vnl_math::sqrt2¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:96:14:
>error: uninitialized const Œvnl_math::sqrt2¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:97:24:
>error: Œconst double vnl_math::sqrt1_2¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:97:14:
>error: uninitialized const Œvnl_math::sqrt1_2¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:98:24:
>error: Œconst double vnl_math::euler¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:98:14:
>error: uninitialized const Œvnl_math::euler¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:101:24:
>error: Œconst double vnl_math::eps¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:101:14:
>error: uninitialized const Œvnl_math::eps¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:102:24:
>error: Œconst double vnl_math::sqrteps¹ is not a static member of Œclass
>vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:102:14:
>error: uninitialized const Œvnl_math::sqrteps¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:105:23:
>error: Œconst float vnl_math::float_eps¹ is not a static member of
>Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:105:13:
>error: uninitialized const Œvnl_math::float_eps¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:106:23:
>error: Œconst float vnl_math::float_sqrteps¹ is not a static member of
>Œclass vnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:106:13:
>error: uninitialized const Œvnl_math::float_sqrteps¹ [-fpermissive]
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:
>In static member function Œstatic double
>vnl_math::angle_0_to_2pi(double)¹:
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:291:16:
>error: Œpi¹ is not a member of Œvnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:292:28:
>error: Œpi¹ is not a member of Œvnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:294:12:
>error: Œpi¹ is not a member of Œvnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:294:47:
>error: Œpi¹ is not a member of Œvnl_math¹
>/home/ajg23/DEVEL/src/ITK/Modules/ThirdParty/VNL/src/vxl/core/vnl/vnl_math
>.cxx:304:21:
>error: Œpi¹ is not a member of Œvnl_math¹
>make[2]: ***
>[Modules/ThirdParty/VNL/src/vxl/core/vnl/CMakeFiles/itkvnl.dir/vnl_math.cx
>x.o]
>Error 1
>make[2]: *** Waiting for unfinished jobs....
>
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Kitware offers ITK Training Courses, for more information visit:
>http://kitware.com/products/protraining.php
>
>Please keep messages on-topic and check the ITK FAQ at:
>http://www.itk.org/Wiki/ITK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://www.itk.org/mailman/listinfo/insight-developers



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list