struct member alignment

From: Jana Andropov (asdf_at_asdf.com)
Date: 01/19/05


Date: Wed, 19 Jan 2005 08:38:20 -0500

hi all,
i'm having a problem with struct member alignment settings in dev studio 6.
it's currently set to the default which is 8 byte alignment, however,
despite this fact i'm still unable to calculate
what "sizeof" will return when i call it on my structs even though i know
its aligning to 8 byte boundaries.

definition from documentation (/Zp):
each structure member after the first is stored on either the size of the
member type or n-byte boundaries (where n is 1, 2, 4, 8, or 16), whichever
is smaller
eg.
struct aaa
{
   int x;
   double y;
   int z;
};

sizeof returns a size of 24. i dont know why. can someone explain this to
me?



Relevant Pages

  • Re: Linked list w/ structure
    ... I have no problem when first_name in the structure is an int. ... typedef struct member ... RECORD *head, *p; ... Language: C ...
    (comp.lang.c)
  • Linked list w/ structure
    ... I have no problem when first_name in the structure is an int. ... typedef struct member ... RECORD *head, *p; ... Language: C ...
    (comp.lang.c)
  • Struct member undetected by compiler
    ... when I run the code below, it gives the compiler error at the bottom of ... I am not sure why it cann't see the struct member. ... 5-0.cpp: In function `int main': ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Fat pointers
    ... Taking the address of a struct member? ... (You don't need to change any compilers, just say, "this ... following code invoke undefined behavior? ... struct foo {int a,b,c;} bar; ...
    (comp.lang.c)
  • char conversion problem
    ... the function is suppose to check the fifth digit of struct member ... int checkdigit; ...
    (comp.lang.cpp)

Loading