Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Small Variant Records in C |
| Date | 2011-12-19 02:25 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <jcm7d3$e0s$1@dont-email.me> (permalink) |
| References | (1 earlier) <slrnjeseuh.51v.usenet-nospam@guild.seebs.net> <jclgp9$d9r$1@dont-email.me> <cd16434c-8c43-4b2f-b293-b12ec9bc8d6f@o7g2000yqk.googlegroups.com> <slrnjeslun.8g9.usenet-nospam@guild.seebs.net> <b31838b4-399d-452e-9531-9fa92b5d09db@m10g2000vbc.googlegroups.com> |
"Marco Devillers" <marco.devillers@gmail.com> wrote in message news:b31838b4-399d-452e-9531-9fa92b5d09db@m10g2000vbc.googlegroups.com... > >> You can't necessarily. You really have to use the union type in most >> cases or the compiler will assume the types can't alias each other. > > Hmpf, so does a trick with not allocating more than the size of a > specific member of the union work? > > I mean, the game is to have a variant type where each subtype > allocates a minimal number of bits (rounded of by a word size I > chose). Is there a solution? How important is it to have the minimum number (of bytes usually rather than bits)? What is the largest variant size likely? If your primitives are only going to be ints and doubles, it might simpler to have everything the same size (for example it means everything might be 12 bytes, instead of 8 bytes for ints and 12 for doubles). This can avoid some of the issues mentioned. (And I don't know how you do arrays, but if you want arrays with mixed elements, it will help there as well. If array elements are homogeneous, then they don't need to be tagged at all, then your variants would only be used outside of arrays, so the size is less significant.) -- Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 10:16 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-18 18:50 +0000
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 15:00 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 12:23 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-18 21:15 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 14:13 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-19 00:26 +0000
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 02:25 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 19:08 -0800
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 17:24 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 11:43 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 15:21 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 13:38 -0800
Re: Small Variant Records in C James Kuyper <jameskuyper@verizon.net> - 2011-12-19 16:48 -0500
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 17:19 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 15:14 -0800
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 21:44 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-19 14:02 -0800
Re: Small Variant Records in C Kaz Kylheku <kaz@kylheku.com> - 2011-12-19 18:38 +0000
Re: Small Variant Records in C jgk@panix.com (Joe keane) - 2012-01-04 03:52 +0000
Re: Small Variant Records in C Ian Collins <ian-news@hotmail.com> - 2012-01-04 20:25 +1300
Re: Small Variant Records in C Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 15:53 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 18:35 -0500
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 16:01 -0800
Re: Small Variant Records in C Seebs <usenet-nospam@seebs.net> - 2011-12-19 00:26 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 17:02 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-18 19:53 -0500
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 01:36 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 18:21 -0800
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 02:52 +0000
Re: Small Variant Records in C Marco Devillers <marco.devillers@gmail.com> - 2011-12-18 19:17 -0800
Re: Small Variant Records in C Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-19 09:24 -0500
Re: Small Variant Records in C "BartC" <bc@freeuk.com> - 2011-12-19 17:18 +0000
csiph-web