Re: [CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr
On 03/16/2015 03:05 AM, Roman Wüger wrote: > attached is an updated patch. Applied, thanks: WCDH: Fix cxx_nullptr workaround for pre-C++11 compilers http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9d09626 -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr
Hi Brad, attached is an updated patch. Roman From ea75cb1a3d866d923b6711c9e0c0bbf1f66d7dbf Mon Sep 17 00:00:00 2001 From: Roman Wüger Date: Fri, 13 Mar 2015 09:18:19 +0100 Subject: [PATCH] WCDH: Fix cxx_nullptr for compilers which doesn't support C++11 --- Modules/WriteCompilerDetectionHeader.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index d18f47c..f4dcb21 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -586,7 +586,7 @@ function(write_compiler_detection_header # if ${def_name} #define ${def_value} nullptr # else -#define ${def_value} static_cast(0) +#define ${def_value} 0 # endif \n") endif() -- 1.9.5.msysgit.0 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
Re: [CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr
On 03/11/2015 05:22 PM, Roman Wüger wrote: > This simple example produces the following error on Mac OS: > error: cannot initialize a parameter of type 'bool *' with an rvalue of type > 'void *' > void doSomething(int n = 1, bool *ok = static_cast(0)) { > ^~ Indeed. It looks like it was written that way originally in the module: Add the WriteCompilerDetectionHeader module. http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62a4a67d There is a proposed library-only implementation of nullptr here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf "1.1 Alternative #1: A Library Implementation of nullptr" but that is probably too complicated for this compatibility macro that is just supposed to provide the advantages of C++11 when it is available but otherwise work as normal C++98. On 03/12/2015 06:59 AM, Roman Wüger wrote: > -#define ${def_value} static_cast(0) > +#ifdef NULL > +# define ${def_value} NULL > +#else > +# define ${def_value} 0 > +#endif In C++98, NULL is always just "0" AFAIK so the condition may not be needed. I think it is cleaner to not have the definition depend on the order of includes (whether a standard header provides NULL). Thanks, -Brad -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
[CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr
Hello, I've attached a patch for this problem. Best Regards From 3b77b957a41ce00c8e5d8d47ce442887181d669d Mon Sep 17 00:00:00 2001 From: Roman Wüger Date: Thu, 12 Mar 2015 11:51:24 +0100 Subject: [PATCH] WCDH: Fix cxx_nullptr for compilers which doesn't support C++11 --- Modules/WriteCompilerDetectionHeader.cmake | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index d18f47c..721bbdb 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -586,7 +586,11 @@ function(write_compiler_detection_header # if ${def_name} #define ${def_value} nullptr # else -#define ${def_value} static_cast(0) +#ifdef NULL +# define ${def_value} NULL +#else +# define ${def_value} 0 +#endif # endif \n") endif() -- 1.9.5.msysgit.0 -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
[CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr
Hello, i tried to use the generated compiler detection header but get an error if I use the cxx_nullptr feature on a compiler which doesnt support C++11. void doSomething(int n, bool *ok = 0) { if (ok) *ok = true; if (n != 0) { if (ok) *ok = false; } } This simple example produces the following error on Mac OS: error: cannot initialize a parameter of type 'bool *' with an rvalue of type 'void *' void doSomething(int n = 1, bool *ok = static_cast(0)) { ^~ However, if C++11 could be used then the nullptr is working fine. Couldnt static_cast(0) simply be replaced with 0? Best Regards -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake