Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Stephen Sprunk <stephen@sprunk.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Are struct members are also padded? |
| Date | 2011-06-12 16:32 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <it3b9b$ha1$1@dont-email.me> (permalink) |
| References | <it39te$if3$1@speranza.aioe.org> |
On 12-Jun-11 16:09, 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).
The sizes will vary from one implementation to another, sometimes even
on the same machine, so there are no universal answers.
If you need to worry about this, it would be more effective to address
the portability problems with your code so that the size is irrelevant,
rather than try to predict what machines it will run on and figure out
how to handle each case.
S
--
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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