Re: Utilty for parsing raw data into C structures
From: Pat Ford (pat.ford_at_nrc.ca)
Date: 09/30/04
- Next message: donno: "problem with simple clock() call"
- Previous message: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- In reply to: QNils_O=2E_Sel=E5sdal=22?=: "Re: Utilty for parsing raw data into C structures"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Sep 2004 07:25:02 -0400
"Nils O. Selåsdal" <NOS@Utel.no> wrote in message
news:9eP6d.12593$g%5.162430@news2.e.nsc.no...
> Pat Ford wrote:
> > "Karthik K R" <shukart1@yahoo.com> wrote in message
> > news:44bd5fac.0409290606.69a9d264@posting.google.com...
> >
> >
> >
> >
> > how about;
> >
> > //================== in the header file
> > typedef struct {
> > u_int16_t jmp_opcode; // this is always a 6
> > u_int16_t Buffer; // the is the offset for the satrt of the
main
> > program
> > u_int16_t Naddr; // number of addresses in the setup section
> > u_int16_t CASES; // the number of cases in the program
> > u_int16_t highChannelBitmap; // channel addresses in the range of
E940
> > to E95A
> > u_int16_t lowChannelBitmap; // channel addresses in the range of
E740
> > to E75A
> > u_int16_t subcases; // the number of subcases of option 0xD
> > u_int16_t spare; // unused
> > u_int16_t FUNCT[8]; // starting addresses of upto 8 functions this
is
> > an offset from tble
> > HomeType home[20]; // this array hold the value and address for
each
> > "safe"
> > // position. the number comes from refer.h AddressTableLimit
> > u_int16_t poo[16];
> > }RefHeaderType;
> Depending what's the structure of the data is in
> }RefHeaderType __attribute__((__packed__));
> might be needed when mapping data directly to C structures.
Good catch, the latter revisions of this system use the packed attribute.
As a note to others, packed forces the compiler to do what you think when
you use a structure, not align it on word. quadword or other boundaries.
This becomes important if your structure is accessed by a program that was
built with a different compiler.
In my case this structure goes on to a reflective memory network, it is
built on redhat9 has an NT and a W98 client and a few other RH9 machines all
reading it. Not using the packed allowed the structure to work great on all
RH9 but fail on the others and caused a week of headaches.
Pat
- Next message: donno: "problem with simple clock() call"
- Previous message: Måns Rullgård: "Re: Utilty for parsing raw data into C structures"
- In reply to: QNils_O=2E_Sel=E5sdal=22?=: "Re: Utilty for parsing raw data into C structures"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|