C
Capstar
Hi NG,
I have a question about the usage of bitfileds in a structure.
for instance:
struct pcard
{
unsigned pips : 4;
unsigned suit : 2;
};
The only reason I see fot using this is to save memory. But isn't it true
that on most systems memory isn't that much of an issue to pack data like
this? And even on some embedded machine whitout much memory, I'm not sure
the memory gain by packing your structures will be much bigger than the loss
you get from the increased code size. Maybe when you have lots of these
structures you will gain something.
Another reason I would consider this helpfull would be if the structures
would be written to some binary file. In my opinion file size does matter.
The only problem I see in this case is that every machine, and even a
different compiler at the same machine, could map the bits somewhere else in
a word. This would mean that the file is incompatible with anything but the
same compiler and the same machine.
So I am very curious if anybody ever uses these kind of structures and where
they are used for.
Mark
I have a question about the usage of bitfileds in a structure.
for instance:
struct pcard
{
unsigned pips : 4;
unsigned suit : 2;
};
The only reason I see fot using this is to save memory. But isn't it true
that on most systems memory isn't that much of an issue to pack data like
this? And even on some embedded machine whitout much memory, I'm not sure
the memory gain by packing your structures will be much bigger than the loss
you get from the increased code size. Maybe when you have lots of these
structures you will gain something.
Another reason I would consider this helpfull would be if the structures
would be written to some binary file. In my opinion file size does matter.
The only problem I see in this case is that every machine, and even a
different compiler at the same machine, could map the bits somewhere else in
a word. This would mean that the file is incompatible with anything but the
same compiler and the same machine.
So I am very curious if anybody ever uses these kind of structures and where
they are used for.
Mark