James Carlson <[EMAIL PROTECTED]> wrote: > Garrett D'Amore writes: > > I have macros like those above, yes. (Although in my code it looks more > > like this:) > > > > #define BIT(x) (1UL << (x)) > > ... > > #define MYMASK BIT(4) > > I'm surprised nobody's mentioned C structures with bit fields. I've > used those to good effect on hardware in the past. (Yes, getting the > access width right, particularly on writes, can be a pain on some > devices.)
The C standard grants that these structures are not portable..... All known C-compilers give a limited portability if you take care of declaring them the right way. - You need to use "unsigned char" as type unless you use the IBM C-compiler - You may not define them to have more bits than an int - You take care of alignement - You take care about Bit-ordering (this may be different from Byte-order see Plan 9 compiler...) Cdrecord uses bitfields for SCSI structures but as you see from above, you definitely need autoconf to get the right definition for the current compile platform. Jörg -- EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin [EMAIL PROTECTED] (uni) [EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code