bit fields

Daniel_Roedding at fiction.uucp Daniel_Roedding at fiction.uucp
Sat Jun 9 00:42:00 AEST 1990


Several times I used bit fields to save memory, but I got some trouble when
passing them as parameters to functions.

Take the following example:

typedef struct { ... } the_bitfield;

void somefunct(the_bitfield *argh) {
  /* some stupid code going here */
}

Most compilers do not eat this, since ANSI doesn't allow pointers to
bitfield structures.

I didn't find any way to submit a bitfield-parameter to a function. It
is obvious that pointers to bitfield components aren't allowed, but why
is there no way to get a pointer to the whole structure. ANSI defines a
bitfield to be of the size of an int, so one should get a pointer to it...

I don't want to transfer the parameter by value, because my compiler seems
to create quite stupid code when passing a structured type by value. Further-
more, the function may alter the passed bitfield.

Any solutions?

Daniel

Daniel Roedding         uucp: ..!osu-cis!watzman!tjack!fiction!daniel
Geiststrasse 32               daniel%fiction at watzman.as.sub.org
D-4400 Muenster
++49 251 525306         /* Germans don't need a disclaimer... :-) */



More information about the Comp.lang.c mailing list