This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

packing


Hi,

I'd like to use the following bitfield for dataexchange via a file.

typedef unsigned int uint32_t;

typedef struct dataHeader_s
{
  uint32_t func:8;
  uint32_t len:24;
}
dataHeader_t;

I expect this struct to have a size of 4 bytes. The program which has to read the file using this struct, (xine) is compiled using gcc. It seems, that the program is compiled with proper options, because at this program, the size of the above structure is 4 bytes.

But the program which writes the file (VDR), is compiled with g++ and seems to lack some options, because at that program, the size of the structure is 8 bytes.

I've already tried the following definition:

typedef struct __attribute__((packed)) dataHeader_s
{
  int32_t func:8;
  int32_t len:24;
}
dataHeader_t;

For xine, this structure still has 4 byte in size, but for VDR, this structure now has 5 bytes and I haven't found any solution yet to get it to 4 bytes. Even with using a lot of the compiler switches from xine when compiling VDR, I don't get this structure to have a size of 4 bytes.

What am I doing wrong?

Maybe someone can tell me the necessary compiler switches or structure attributes.

Bye.
--
Dipl.-Inform. (FH) Reinhard Nissl
mailto:rnissl@gmx.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]