[cmake-developers] CheckStructHasMember does not support C++ only structs
Daniele E. Domenichelli
daniele.domenichelli at gmail.com
Fri Oct 4 09:35:07 EDT 2013
On 04/10/13 12:20, Rolf Eike Beer wrote:
> Just some thoughts:
> -some compilers may error out because you dereference an uninitialized
> pointer
> -some compilers may complain because you perform an operation that does
> nothing, maybe prepend it with a (void) to mark that as intentional
This is the test that is currently executed, I just added some tests...
> What about this:
>
> struct struct_with_member tmp, *tmpp;
> tmp.foo = 0;
> tmpp = &tmp;
> return tmpp->foo;
I saw at leas one case where CheckStructHasMember is used to check if a
struct has a method, so "foo()" instead of "foo"...
With such a change "tmp.foo() = 0" will fail, so it looks like a non
compatible change to me.
Also this requires that the struct has a public constructor.
If you are not against it, I would also like to change "int main()" to
"int main(int argc, char **argv)" because I found a library (ACE [1])
that causes the test to fail on windows due to some weird define (see [2])
[1]http://www.cs.wustl.edu/~schmidt/ACE.html
[2]http://doxygen.theaceorb.nl/libace-doc/a01553_source.html
So what about something like this?
int main(int argc, char **argv)
{
(void)(argc); // To avoid warnings for unused parameters
(void)(argv);
struct struct_with_member *tmp = 0;
void *tmpv = (void*)&(tmp->foo);
(void)(tmpv);
return tmpv;
}
Cheers,
Daniele
More information about the cmake-developers
mailing list