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
-- 

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

Reply via email to