I have a problem with typedef union as parameter for a function-call.
definition of the typedef
union uParameter { byte bByte; // 8 bit unsigned int16 iInt16; // 16 bit signed int32 iInt32; // 32 bit signed }; typedef union uParameter USR_tu_Para;
prototype of a function that uses this typedef
void SetSomething(USR_tu_Para para);
The question is: how can I call the SetSomething-function with a constant parameter.
SetSomething(100);
This call creates a compiler error: #167: argument of type "int" is incompatible with parameter of type "USR_tu_Para"
I tried to cast the parameter witch (USR_tu_Para) or (USR_tu_Para.iInt16). But the compiler denied everything I tried.
Any ideas?
Sounds like all the more reason not to be using any "cunning tricks" like this at all!
For portability, you want to stick to making things as "straightforward" as possible - messing with unions and/or void* pointers sounds like a great way to run into all sorts of implementation-dependant traps...