[cmake-developers] CheckStructHasMember does not support C++ only structs

Daniele E. Domenichelli daniele.domenichelli at gmail.com
Mon Sep 23 04:27:20 EDT 2013


Hello,

CheckStructHasMember does not support C++ only structs. If headers
required to check if a struct has a member can be compiled with C++
compiler only, the check will fail, because the C compiler will fail. As
a consequence, the result variable is set to false, even if the struct
has that particular member.

The attached patch adds 2 new macros:
 - CHECK_CXX_STRUCT_HAS_MEMBER (similar to CHECK_STRUCT_HAS_MEMBER but
uses the C++ compiler)
 - CHECK_C_STRUCT_HAS_MEMBER (identical to CHECK_STRUCT_HAS_MEMBER,
added for symmetry)
that can be used to check a struct, choosing the compiler to use.

I'm not sure if this is the right way to fix this (i.e. if
CHECK_C_STRUCT_HAS_MEMBER is required), or if it is a better idea to add
a parameter to the existing macro.
What do you think?


Cheers,
 Daniele

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-CheckStructHasMember-Add-support-for-C.patch
Type: text/x-patch
Size: 2450 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20130923/3ad5901a/attachment-0002.bin>


More information about the cmake-developers mailing list