Aaron Ardiri wrote :

>why not use a macro to make
>your code easier to understand at the same time :)
>
>#define RGBColorTypeSet(a, val) (*((UInt32 *)(a)) = (val)
>#define RGBColorTypeCompare(a, b) ( (*((UInt32 *)(a)) == *((UInt32 *)(b))) )
>
>then do:
>
>RGBColorTypeSet(&a, 0xffffffffL);
>RGBColorTypeSet(&b, 0x80800101L);
>if (RGBColorTypeCompare(&a, &b))
>{
>.. same
>}
>else
>{
>.. different
>}

Actually, there was an extra parenthesis, it should be:

>#define RGBColorTypeSet(a, val) (*(UInt32 *)(a)) = (val)

Alas, if you want to copy a RGB color into another one, like:

RGBColorTypeSet(a,b); doen't work

and if you make the macro:

>#define RGBColorTypeSet(a, val) (*(UInt32 *)(a)) = (*(UInt32 *)(val))

then RGBColorTypeSet(&a, 0xffffffffL); cannot work because val is
not a pointer. So you need 2 macros for setting, depending on the
source, or cast val when calling the macro:

RGBColorTypeSet(a, *(UInt32 *)b);


Luc Le Blanc
-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/

Reply via email to