Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #103479
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Preprocessor expressions |
| Date | 2017-02-08 09:19 -0800 |
| Organization | None to speak of |
| Message-ID | <lntw84zjkj.fsf@kst-u.example.com> (permalink) |
| References | (11 earlier) <1e988be1-ec21-4335-8f79-e6d1e213f1c7@googlegroups.com> <o7dcfu$69q$1@dont-email.me> <86f1f0c5-5f44-4bab-8cd2-074b407220e8@googlegroups.com> <o7dgfs$ksp$1@dont-email.me> <o7emp7$ikl$1@dont-email.me> |
David Brown <david.brown@hesbynett.no> writes:
[...]
> If you want to avoid structs being smaller than you expect, add padding
> explicitly.
>
> So with
>
> struct X {
> double b; // 64 bits
> int a; // 32 bits
> int c; // 32 bits
> };
>
> You will always get 16 byte structs with 8 byte alignment (assuming
> CHAR_BIT == 8).
*And* assuming that double is 64 bits and int is 32 bits. Neither is
guaranteed.
If you're implementing something that generates C code, and if the
translator and/or the generated C code are intended to be reasonably
portable, it's probably a good idea for the generator to be aware of
some of the characteristics of the target system. In some cases, some
of this parameterization has already been done by <stdint.h>.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Preprocessor expressions BartC <bc@freeuk.com> - 2017-01-22 13:24 +0000
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-01-22 07:52 -0800
Re: Preprocessor expressions Ralf Damaschke <rwspam@gmx.de> - 2017-01-22 17:15 +0000
Re: Preprocessor expressions "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-22 13:32 -0500
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-01-22 17:38 +0000
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-01 03:12 -0800
Re: Preprocessor expressions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-01 11:44 +0000
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-01 11:56 +0000
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-02-01 08:35 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-02 09:23 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-02 18:14 +0000
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-02 10:35 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-02 17:09 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-05 10:09 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-05 10:38 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-05 11:03 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-06 15:17 +0000
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-07 05:36 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-07 21:01 +0000
Re: Preprocessor expressions supercat@casperkitty.com - 2017-02-07 13:16 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-07 22:09 +0000
Re: Preprocessor expressions supercat@casperkitty.com - 2017-02-07 14:33 -0800
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-07 14:52 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-08 00:13 +0000
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-07 16:39 -0800
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-02-07 16:47 -0800
Re: Preprocessor expressions David Brown <david.brown@hesbynett.no> - 2017-02-08 10:03 +0100
Re: Preprocessor expressions Keith Thompson <kst-u@mib.org> - 2017-02-08 09:19 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-08 12:35 -0800
Re: Preprocessor expressions Thiago Adams <thiago.adams@gmail.com> - 2017-02-09 05:25 -0800
Re: Preprocessor expressions supercat@casperkitty.com - 2017-02-09 07:37 -0800
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-02-09 15:52 +0000
Re: Preprocessor expressions BartC <bc@freeuk.com> - 2017-01-22 19:34 +0000
Re: Preprocessor expressions jameskuyper@verizon.net - 2017-01-22 13:01 -0800
Re: Preprocessor expressions Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-30 05:30 -0800
csiph-web