sizeof()
Re: sizeof()
Perhaps. Since it is always evaluated at compile-time, we could probably change it to a special internal "integral" type that is compatible with (e.g. can be assigned to) all integral types.stevech wrote:shouldn't "sizeof()" return an unsigned int rather than an int?
- Don Kinzer
can't sizeof() be evaluated at compile time if the arg is known? I use that in C when defining nested structs and unions (no forward references).
On unions...
In ZBasic, can one emulate a C union as such (I use this construct a lot)
were I want to access the data as an array of bytes as well as its structured type? (knowing to watch data alignment). I do this kind of thing when sending a struct of binary types as a byte stream, as in communications protocols.
On unions...
In ZBasic, can one emulate a C union as such (I use this construct a lot)
or is there a better way to mimic a union?public headerMAC16 as MACheader_t
public headerMAC16_bytes() as byte based headerMAC16.dataAddress ' like a union in C
were I want to access the data as an array of bytes as well as its structured type? (knowing to watch data alignment). I do this kind of thing when sending a struct of binary types as a byte stream, as in communications protocols.
Unions are supported in v4.0.0. See www.zbasic.net/doc/ZBasicRef.php?page=99. Unions were added primarily in support of importing C/C++ header files but they are useful in their own right.stevech wrote:In ZBasic, can one emulate a C union as such (I use this construct a lot)
- Don Kinzer