On Wed, 21 Mar 2001, Daniel A. Koepke wrote:
>For the completeness of the solution, however, bitfields have their
>disadvantages: the presumed complexity of code to write them without
>knowing each flag you're writing (mainly for ASCII pfiles; you could know
>them all, but that'd remove one of the principle advantages of bitfields
>from client coders: that they just add the flag and that's it for that),
>the fact that if you don't pad the structures you can't extend them when
>using binary files with static record sizes, etc.
Just use a union (not 100%-perfect syntax):
union {
struct {
unsigned x : 1;
unsigned y : 1;
unsigned y : 1;
};
unsigned long[8];
}
Then you can pad, and you can iterate over it with numbers. We could do
this right now, excepting byte order on different platforms.
--
George Greer
greerga@circlemud.org
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/04/01 PST