From: David D. <dav...@gm...> - 2011-12-29 01:19:40
|
If I enable the c++0x flag, I get lots of "error: ‘constexpr’ needed for in-class initialization of static data member ‘float_sqrteps’ of non-integral type" errors in vxl/core/vnl/vnl_numeric_traits.h and vnl_math.h. It seems like float in-class initialization are deprecated (the last item here: http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html). Are there any plans to allow code that uses VXL to compile with this flag? Thanks, David |
From: David D. <dav...@gm...> - 2011-12-29 01:47:12
|
On Wed, Dec 28, 2011 at 8:19 PM, David Doria <dav...@gm...> wrote: > If I enable the c++0x flag, I get lots of "error: ‘constexpr’ needed > for in-class initialization of static data member ‘float_sqrteps’ of > non-integral type" errors in vxl/core/vnl/vnl_numeric_traits.h and > vnl_math.h. It seems like float in-class initialization are deprecated > (the last item here: > http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html). Are there > any plans to allow code that uses VXL to compile with this flag? Moving these initialization outside of the class body fixes the errors. http://review.source.kitware.com/#/c/3583/ It didn't seem to me like the VCL_STATIC_CONST_INIT_FLOAT_DECL macro was doing anything, and it wouldn't compile with it once I moved the initializations, but it seems to compile and work fine at least on gcc. Any comments on if this is the right thing to do? David |
From: Peter V. <pet...@ya...> - 2011-12-29 10:39:08
|
David: I agree in principle: we should indeed move towards the C++ standard wherever possible. Actually, that has been the goal since day one of vxl. And that's exactly what VCL_STATIC_CONST_INIT_FLOAT_DECL and VCL_STATIC_CONST_INIT_FLOAT_DEFN are meant for: compilers that allow static const float initialisation (i.e.: non-standard-compliant gcc compilers) will not need to instantiate e.g. vnl_math::pi (in vnl_math.cxx) but have its definition visible in vnl_math.h; this allows users of vnl_math.h to not link against the vnl library. Standard-compliant compilers, on the other hand, will instantiate vnl_math::pi in vnl_math.cxx So I guess your compile error is caused by using the c++0x compile flag without having modified the (generated) file vcl/vcl_config_compiler.h in the build tree as follows: # define VCL_CAN_STATIC_CONST_INIT_INT 0 Your proposed modifications to vnl_math.h & vnl_math.cxx will actually be happening automatically if you modify vcl_config_compiler.h this way. We could easily force all compilers into this standard-compliant mode by modifying line 143 of vcl/vcl/config_compiler.h.in as follows: #define VCL_CAN_STATIC_CONST_INIT_FLOAT 0 /* not allowed */ (i.e.: removing the "//") This makes your patch unnecessary. (See the comment just above that line 143: the designers of this file were aware of the fact that this feature is not standard-compliant.) What do you think? -- Peter. ________________________________ Från: David Doria <dav...@gm...> Till: vxl...@li... Skickat: 29 december 2011 2:19 Ämne: Compiling with gcc and c++0x If I enable the c++0x flag, I get lots of "error: ‘constexpr’ needed for in-class initialization of static data member ‘float_sqrteps’ of non-integral type" errors in vxl/core/vnl/vnl_numeric_traits.h and vnl_math.h. It seems like float in-class initialization are deprecated (the last item here: http://gcc.gnu.org/onlinedocs/gcc/Deprecated-Features.html). Are there any plans to allow code that uses VXL to compile with this flag? Thanks, David -- |
From: David D. <dav...@gm...> - 2011-12-29 13:51:40
|
On Thu, Dec 29, 2011 at 5:39 AM, Peter Vanroose <pet...@ya...> wrote: > David: > > I agree in principle: we should indeed move towards the C++ standard > wherever possible. > Actually, that has been the goal since day one of vxl. > And that's exactly what VCL_STATIC_CONST_INIT_FLOAT_DECL and > VCL_STATIC_CONST_INIT_FLOAT_DEFN are meant for: compilers that allow static > const float initialisation (i.e.: non-standard-compliant gcc compilers) will > not need to instantiate e.g. vnl_math::pi (in vnl_math.cxx) but have its > definition visible in vnl_math.h; this allows users of vnl_math.h to not > link against the vnl library. Standard-compliant compilers, on the other > hand, will instantiate vnl_math::pi in vnl_math.cxx > > So I guess your compile error is caused by using the c++0x compile flag > without having modified the (generated) file vcl/vcl_config_compiler.h in > the build tree as follows: > # define VCL_CAN_STATIC_CONST_INIT_INT 0 > Your proposed modifications to vnl_math.h & vnl_math.cxx will actually be > happening automatically if you modify vcl_config_compiler.h this way. > > We could easily force all compilers into this standard-compliant mode by > modifying line 143 of vcl/vcl/config_compiler.h.in as follows: > #define VCL_CAN_STATIC_CONST_INIT_FLOAT 0 /* not allowed */ > (i.e.: removing the "//") > This makes your patch unnecessary. > (See the comment just above that line 143: the designers of this file were > aware of the fact that this feature is not standard-compliant.) > > What do you think? > > -- Peter. Peter, That works for me, and it is certainly an easy fix. However, if we are going to force every complier to comply - why not get rid of all of the VCL_CAN_STATIC_CONST* defines all together and just move the variable definitions into the initialization list (my patch actually had "undefined const" errors, but moving them to the initialization lists should work)? It would certainly be more clear and consistent. Do you see a problem with this method on other platforms? If not, let me know and I'll work on the patch. If so, you could go ahead and merge the one line patch that you proposed. Thanks, David |
From: Amitha P. <am...@th...> - 2011-12-29 23:20:08
|
David, The choice to use or not use the inline float initialization is based on a try-compile. If you are having issues, I'd guess that your configuration is stale. Or perhaps your vxl build uses a different compiler than whatever you are using vxl for? Note that having different compilers (or compiler flags) for a library and for a program using that library is fraught with peril, is suggested only for advanced users, and is not supported. This is especially true for C++. The try-compile test is performed here: vxl/src/config/cmake/config/CMakeLists.txt:70 Perhaps try re-configuring your build after deleting the cache? Or else try setting VXL_UPDATE_CONFIGURATION to "ON" and re-running CMake. If this does not work, I'd like to fix the try-compile, rather than eliminating the feature. If necessary, we could also create a setting to forcefully disable this feature. I think the solution that is currently in place allows the system to work on all platforms *and* leverage, where possible, some extensions that make faster the use of some floating point constants. Amitha. |
From: David D. <dav...@gm...> - 2011-12-29 16:43:56
|
On Thu, Dec 29, 2011 at 9:38 AM, Amitha Perera <am...@th...> wrote: > David, > > The choice to use or not use the inline float initialization is based on a > try-compile. If you are having issues, I'd guess that your configuration is > stale. Or perhaps your vxl build uses a different compiler than whatever > you are using vxl for? > > Note that having different compilers (or compiler flags) for a library and > for a program using that library is fraught with peril, is suggested only > for advanced users, and is not supported. This is especially true for C++. > > The try-compile test is performed here: > vxl/src/config/cmake/config/CMakeLists.txt:70 > > Perhaps try re-configuring your build after deleting the cache? Or else try > setting VXL_UPDATE_CONFIGURATION to "ON" and re-running CMake. If this does > not work, I'd like to fix the try-compile, rather than eliminating the > feature. If necessary, we could also create a setting to forcefully disable > this feature. > > I think the solution that is currently in place allows the system to work on > all platforms *and* leverage, where possible, some extensions that make > faster the use of some floating point constants. > > Amitha. Amitha, I am using the VXL that ships with ITK. I started from scratch (fresh build directory), this time just trying to build ITK itself with the -std=gnu++0x flag, and got the same errors. Please let me know if you have anything else I can try, or if you'd like me to see if it works once a patch is proposed. Thanks, David |
From: Brad K. <bra...@ki...> - 2012-01-02 18:13:23
|
On 12/29/2011 11:43 AM, David Doria wrote: > On Thu, Dec 29, 2011 at 9:38 AM, Amitha Perera <am...@th...> wrote: >> The choice to use or not use the inline float initialization is based on a >> try-compile > > I am using the VXL that ships with ITK. I started from scratch (fresh > build directory), this time just trying to build ITK itself with the > -std=gnu++0x flag, and got the same errors. The try-compile correctly rejects the option for me: $ mkdir ITK-build && cd ITK-build $ export CXX=g++ CXXFLAGS=-std=gnu++0x $ cmake ../ITK -DITK_BUILD_ALL_MODULES=OFF -DBUILD_EXAMPLES=OFF \ -DITKGroup_Core=OFF -DModule_ITKVNL=ON ... -- Enabled ITKVNL, requested by Module_ITKVNL. ... -- Performing Test VCL_STATIC_CONST_INIT_FLOAT -- Performing Test VCL_STATIC_CONST_INIT_FLOAT - Failed ... $ cat CMakeFiles/CMakeError.log ... Performing Test VCL_STATIC_CONST_INIT_FLOAT failed with the following output: /usr/bin/g++ -std=gnu++0x ... -DVCL_STATIC_CONST_INIT_FLOAT ... -c .../vxl_platform_tests.cxx .../vxl_platform_tests.cxx:266:26: error: 'constexpr' needed for in-class initialization of static data member 'x' of non-integral type .../vxl_platform_tests.cxx:267:27: error: 'constexpr' needed for in-class initialization of static data member 'y' of non-integral type .../vxl_platform_tests.cxx: In function 'int main()': .../vxl_platform_tests.cxx:270:21: error: 'x' is not a member of 'A' .../vxl_platform_tests.cxx:270:38: error: 'y' is not a member of 'A' ... $ cat Modules/ThirdParty/VNL/src/vxl/vcl/vcl_config_compiler.h ... //#define VCL_CAN_STATIC_CONST_INIT_FLOAT 1 /* allowed */ //#define VCL_CAN_STATIC_CONST_INIT_FLOAT 0 /* not allowed */ #ifndef VCL_CAN_STATIC_CONST_INIT_FLOAT # define VCL_CAN_STATIC_CONST_INIT_FLOAT 0 #endif ... $ make ...works... -Brad |
From: Williams, N. K <nor...@ui...> - 2012-01-04 17:24:50
|
I have a patch that adds '-Werror=gnu' if CLang++ is the C++ compiler. This gets rid of all the inline static float initializer errors, but it also makes necessary a slight change in vnl_lsqr.cxx because CLang defines __GNUC__, and -Werror=gnu makes all the GNU extensions throw an error. I don't know if there's any place in ITK besides VXL that uses Gnu extensions; the places that VXL uses them seem to me to be of dubious and limited utility, and stink up the source code with #ifdefs. But that's just one man's opinion. On 1/2/12 12:13 PM, "Brad King" <bra...@ki...> wrote: >On 12/29/2011 11:43 AM, David Doria wrote: >> On Thu, Dec 29, 2011 at 9:38 AM, Amitha Perera <am...@th...> >>wrote: >>> The choice to use or not use the inline float initialization is based >>>on a >>> try-compile >> >> I am using the VXL that ships with ITK. I started from scratch (fresh >> build directory), this time just trying to build ITK itself with the >> -std=gnu++0x flag, and got the same errors. > >The try-compile correctly rejects the option for me: > >$ mkdir ITK-build && cd ITK-build >$ export CXX=g++ CXXFLAGS=-std=gnu++0x >$ cmake ../ITK -DITK_BUILD_ALL_MODULES=OFF -DBUILD_EXAMPLES=OFF \ > -DITKGroup_Core=OFF -DModule_ITKVNL=ON >... >-- Enabled ITKVNL, requested by Module_ITKVNL. >... >-- Performing Test VCL_STATIC_CONST_INIT_FLOAT >-- Performing Test VCL_STATIC_CONST_INIT_FLOAT - Failed >... >$ cat CMakeFiles/CMakeError.log >... >Performing Test VCL_STATIC_CONST_INIT_FLOAT failed with the following >output: >/usr/bin/g++ -std=gnu++0x ... -DVCL_STATIC_CONST_INIT_FLOAT ... -c >.../vxl_platform_tests.cxx >.../vxl_platform_tests.cxx:266:26: error: 'constexpr' needed for in-class >initialization of static data member 'x' of non-integral type >.../vxl_platform_tests.cxx:267:27: error: 'constexpr' needed for in-class >initialization of static data member 'y' of non-integral type >.../vxl_platform_tests.cxx: In function 'int main()': >.../vxl_platform_tests.cxx:270:21: error: 'x' is not a member of 'A' >.../vxl_platform_tests.cxx:270:38: error: 'y' is not a member of 'A' >... >$ cat Modules/ThirdParty/VNL/src/vxl/vcl/vcl_config_compiler.h >... >//#define VCL_CAN_STATIC_CONST_INIT_FLOAT 1 /* allowed */ >//#define VCL_CAN_STATIC_CONST_INIT_FLOAT 0 /* not allowed */ >#ifndef VCL_CAN_STATIC_CONST_INIT_FLOAT ># define VCL_CAN_STATIC_CONST_INIT_FLOAT 0 >#endif >... >$ make >...works... > >-Brad >_______________________________________________ >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.html > >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. ________________________________ |