packed/aligned structs problem

bridged with qdn.public.qnxrtp.porting
Post Reply
Alex Cellarius

packed/aligned structs problem

Post by Alex Cellarius » Mon Jan 27, 2003 7:05 pm

I'm porting a DOS application to QNX 6.2.0.
The following struct refuses to be 33 bytes long,
the problem seeming to be around the bit fields.
Although allocated 8 bit, they consume 16.
I've tried putting the bit fields in a struct
with its own __packed__ attribute, but still
no success.

Any ideas-I'm fresh out of any!

union {
char buffer[200];
struct {
unsigned char Frame_Synch_Word1;
unsigned char Frame_Synch_Word2;
unsigned char Packet_Size;
unsigned char Message_ID;
unsigned short adclog_ss;
signed short adclog_bse;
unsigned channel : 3;
unsigned def_channel : 3;
unsigned spare8 : 2;
unsigned short sl_start_count;
unsigned short sl_crc_errors;
unsigned short sl_hours;
unsigned short sl_bit_index;
unsigned short adclog_fwd_pwr;
unsigned short adclog_refl_pwr;
unsigned short bfl_1;
unsigned short bfl_2;
unsigned short bfl_3;
unsigned short bfl_4;
unsigned short bfl_5;
unsigned short Uplink_CRC_Word;
} field __attribute__((__packed__));
} rfh_temp_rx;

John Garvey

Re: packed/aligned structs problem

Post by John Garvey » Mon Jan 27, 2003 9:33 pm

Alex Cellarius <acellarius@systems104.co.za> wrote:
Any ideas-I'm fresh out of any!

} field __attribute__((__packed__));
} __attribute((packed))__ field;

p.s. Also note that the ordering of fields within the
bitfield is unspecified, so be prepared to reverse them.

Alex Cellarius

Re: packed/aligned structs problem

Post by Alex Cellarius » Tue Jan 28, 2003 5:42 am

On 27 Jan 2003 21:33:12 GMT, John Garvey <jgarvey@qnx.com> wrote:
Alex Cellarius <acellarius@systems104.co.za> wrote:
Any ideas-I'm fresh out of any!

} field __attribute__((__packed__));

} __attribute((packed))__ field;

p.s. Also note that the ordering of fields within the
bitfield is unspecified, so be prepared to reverse them.
Thank you!

Post Reply

Return to “qdn.public.qnxrtp.porting”