>From "C++: The Complete Reference", by Herbert Schildt, page 176:
You cannot know, from machine to machine, whether the fields
will run from right to left or from left to right; this implies
that any code using bit-fields may have some machine
dependencies. Other restrictions may be imposed by various
specific implementations, so check the user manual for your
compiler.
A long time ago, I had two Windows C compilers that produced
bitfields in opposite directions. I wasted a lot of time tracking
down that 'bug'. So I no longer trust bitfields. I like bitwise
operators better anyway.
-Ken Jackson
Hynek Sladky writes:
> I think it is a bug because:
>
> struct {
> unsigned short CCC:12;
> unsigned short READ_BL_LEN:4;
> } CSD;
> ----> works as expected (2 bytes long)
>
> struct {
> unsigned short READ_BL_LEN:4;
> unsigned short CCC:12;
> } CSD;
> ----> works wrong (3 bytes long)
>
> I think that this should work the same way shouldn't it?
> Unfortunately I need the second version... :-(
>
> Hynek Sladky
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user