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]

Alignment option question


Hi,

I am having a problem with gcc forcing alignment of short
and long ints in a structure with version 2.8.1 on Solaris
on a Sparc system.

ie:

The struct includes the following fields:
     .
     .
     char rqh_dest_zip        [10];        /* 189-198 */
     char rqh_dest_state      [2];         /* 199-200 */
     char filler_2;                        /* 201     */
     long rqh_cod_amount;                  /* 202-203 */     /*  s9(7)v9(2) 
comp */
     long rqh_quote_amount;                /* 204-207 */     /*  s9(7)v9(2) 
comp */
     .
     .


C code stub:

printf ("rqh_dest_zip     at %ld\n", (long) ((long) 
&lpMsg->rqh_dest_zip[0]   - nMsgStart));
printf ("rqh_dest_state   at %ld\n", (long) ((long) 
&lpMsg->rqh_dest_state[0] - nMsgStart));
printf ("filler_2         at %ld\n", (long) ((long) 
&lpMsg->filler_2          - nMsgStart));
printf ("rqh_cod_amount   at %ld\n", (long) ((long) 
&lpMsg->rqh_cod_amount    - nMsgStart));
printf ("rqh_quote_amount at %ld\n", (long) ((long) 
&lpMsg->rqh_quote_amount  - nMsgStart));


C output:

rqh_dest_zip     at 189
rqh_dest_state   at 199
filler_2         at 201
rqh_cod_amount   at 204
rqh_quote_amount at 208



The problem is that I need 'rqh_cod_amount' to start at the next
byte - 202 - instead of being aligned on the next 32bit offset - 204.

Is there a compiler option that will disable alignment, so I can manage
alignment manually?

Regards,
Bill 

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