Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #5919

Re: Are struct members are also padded?

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Are struct members are also padded?
Date 2011-06-13 09:13 +1200
Message-ID <95kofbFrhmU2@mid.individual.net> (permalink)
References <it39te$if3$1@speranza.aioe.org>

Show all headers | View raw


On 06/13/11 09:09 AM, Tech ID wrote:
> struct pad1 {
>      char c1;
>
> };
>
> struct pad2 {
>      char c1;
>      int x;
>
> };
>
> struct pad3 {
>      char c1;
>      char c2;
>      int x;
>
> };
>
> struct pad4 {
>      char c1;
>      char c2;
>      int x;
>      struct pad1 {
>         char c1;
>      };
>
> };
>
> What will be the sizeof for the structs above? (for 32-bit and 64-bit
> machines).

That depends on the alignment rules and sizeof(int) for that machine. 
There isn't a universal 32 or 64 bit machine.

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Are struct members are also padded? Tech ID <tech@spamtrap.invalid> - 2011-06-12 21:09 +0000
  Re: Are struct members are also padded? Ian Collins <ian-news@hotmail.com> - 2011-06-13 09:13 +1200
  Re: Are struct members are also padded? Shao Miller <sha0.miller@gmail.com> - 2011-06-12 16:13 -0500
  Re: Are struct members are also padded? Angel <angel+news@spamcop.net> - 2011-06-12 21:26 +0000
  Re: Are struct members are also padded? Stephen Sprunk <stephen@sprunk.org> - 2011-06-12 16:32 -0500
  Re: Are struct members are also padded? Keith Thompson <kst-u@mib.org> - 2011-06-12 14:39 -0700

csiph-web