[CMake] Problems with WriteCompilerDetectionHeader and cxx_nullptr
Brad King
brad.king at kitware.com
Thu Mar 12 16:19:44 EDT 2015
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<void*>(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<void*>(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
More information about the CMake
mailing list