Re: bitfields coded

From: Herbert Kremser (kremser@flinux.tu-graz.ac.at)
Date: 11/29/95


On Wed, 29 Nov 1995, Pink Floyd wrote:

> So tell me, can you put more than 32 fields in a bitfield structure?
> Also, do they reliably save/restore from the player file?

Well there's no real true answer to this question.

The C standard say's this is all implementation dependand.
Afaik, the standard forces a bitvector only to accept fields until the
size of a word is reached. (Typically 32bit in a mud environment)

So most implementations will maybe support more than 32 fields, but
you can't rely on that. Some may not allow bitfields across a word
value, most won't support single entries with more bits than the
word length.

For the save/restore i would expect, yes you can rely on that, though
of course binaries in the file won't be portable to other machines,
but thats the case for binary data in general. If you just save a
struct to a file, you can do the same for bitvectors. The chances of
fucking up things are the same.
Of course this is implementation dependand too.  :-)

So in short, use the bitfields across integer boundaries, unless you
want to achieve maximum portability. You best read the documentation of
your compiler to see what is and what is not allowed.
But don't blame any compiler which stops at your code, just go and seek
a better one.   :-)

Herbert
__
[on public request 12 lines of signature deleted]  *snip* ;)



This archive was generated by hypermail 2b30 : 12/07/00 PST