struct padding

Discussion in 'C Programming' started by Fred, May 18, 2009.

  1. Fred

    Fred Guest

    Given a struct
    typedef struct MyStruct {
    SomeType var;
    /* other members */
    } MyStruct;

    is it guaranteed that sizeof(MyStruct) includes sufficient
    padding such that the next byte AFTER a variable of type
    MyStruct will be aligned properly to hold a new variable of
    type SomeType ?

    I presume this must be so since otherwise there could be
    problems accessing members of a MyStruct array.
    --
    Fred K ?
    Fred, May 18, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Fogelklou
    Replies:
    36
    Views:
    1,356
    Chris Fogelklou
    Apr 20, 2004
  2. edware

    struct padding

    edware, Apr 25, 2006, in forum: C Programming
    Replies:
    9
    Views:
    431
    Ed Vogel
    Apr 27, 2006
  3. Hallvard B Furuseth

    Padding bits and struct assignment

    Hallvard B Furuseth, Dec 27, 2006, in forum: C Programming
    Replies:
    5
    Views:
    632
    Eric Sosman
    Dec 27, 2006
  4. Replies:
    11
    Views:
    870
  5. Replies:
    13
    Views:
    343
    glen herrmannsfeldt
    May 5, 2013
Loading...

Share This Page