// Used to cast LargetIntegralType to void* and vice versa.
typedef union ValuePointer {
LargestIntegralType value;
void *pointer;
} ValuePointer;
I'm no C expert, but this looks unportable to me; what happens when void * is smaller than LargestIntegralType on a big-endian machine? You might get luck on a little-endian machine.
Why not use something along the lines of ((void *) value)? Cmockery already uses ((LargestIntegralType) pointer).
Best regards,
-Steve
--
Steve Byan <stev...@me.com>
Littleton, MA 01460
--
You received this message because you are subscribed to the Google Groups "Cmockery" group.
To post to this group, send email to cmoc...@googlegroups.com.
To unsubscribe from this group, send email to cmockery+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cmockery?hl=en.
> union is not endian-portable.
> maybe we should better write it as ((void *) ((uintptr_t)value))
Any particular reason to favor a union over a cast? If we change the definition of the ValuePointer union to use uintptr_t rather than LargestIntegralType, I think it becomes portable.
I've always avoided type-puns in favor of casts, but I'm not a C language lawyer. Maybe there are reasons to favor a union type-pun in cmockery. Any comments? Stewart?