Link to home
Start Free TrialLog in
Avatar of JohnSantaFe
JohnSantaFe

asked on

size of structure member

I know that sizeof() doesn't necessarily return the sum of the sizes for all the structure members because of byte alignment issues.  However, does sizeof() return the correct size when called on the individual members of the structure?  Is this portable?

typedef struct {
    uint8_t a;
    uint16_t b;
    uint32_t c;
} mystruct;

mystruct mystruct;
size_t size;

size = sizeof(mystruct.b)

Will size always equal 2 bytes?

Thanks.

ASKER CERTIFIED SOLUTION
Avatar of stachenov
stachenov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Narendra Kumar S S
Narendra Kumar S S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnSantaFe
JohnSantaFe

ASKER

Thank you.