Re: [cmake-developers] [CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr

2015-03-17 Thread Brad King
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-developers


Re: [cmake-developers] [CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr

2015-03-16 Thread Roman Wüger
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-developers

Re: [cmake-developers] [CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr

2015-03-12 Thread Brad King
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-developers