Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | ootiib@hot.ee |
|---|---|
| Newsgroups | comp.std.c++ |
| Subject | Re: proposal: new bitfield value to ensure structure packing |
| Date | 2013-11-25 08:44 -0800 |
| Organization | unknown |
| Message-ID | <e85511f5-5edb-4820-bf5d-e0af755c4f1e@googlegroups.com> (permalink) |
| References | <d2b978c2-585a-47e2-84a9-f345f7751d32@googlegroups.com> |
On Friday, 22 November 2013 17:04:33 UTC+2, daniel...@googlemail.com wrote:
> My prosal is to enable specifying a bit field length of -1 to tell the
> compiler that in such position it should not insert spaces, or in other
> words, that the previous and next members should be adjacent in memory.
> With this syntax, the FogFrame would end as:
>
> struct FogFrame
> {
> FogFrameHeader header;
> uint8_t: -1; // No spaces here
> uint8_t dummy;
> uint8_t: -1; // Ditto
> int32_t data :22;
> int32_t :10;
> };
Do I understand you correctly that it overrules alignment
requirements?
So for example:
struct A { char c; int i; };
On most current desktops 'A::c' is 1 byte, 'A::i' is 4 bytes and
there is 3-byte padding between them so 'A' is 8 bytes long. Now
you want to have:
struct A { char c; int:-1; int i; };
That removes the above described 3-byte padding?
It can be implemented but the syntax to achieve it looks
unfortunate and also the 'A::i' stops being 'int' in sense one
can't take reference or pointer to it and also it may be split
between different cache pages that normal 'int' never is.
If you want to remove alignment requirements of 'A::i' then
why not simply:
struct A { char c; int i:-1; };
?
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Previous in thread | Next in thread | Find similar
proposal: new bitfield value to ensure structure packing danielgutson@googlemail.com - 2013-11-22 09:04 -0600
Re: proposal: new bitfield value to ensure structure packing ootiib@hot.ee - 2013-11-25 08:44 -0800
Re: proposal: new bitfield value to ensure structure packing James Kuyper <jameskuyper@verizon.net> - 2013-11-25 16:09 -0600
Re: proposal: new bitfield value to ensure structure packing danielgutson@googlemail.com - 2013-11-26 17:19 -0800
Re: proposal: new bitfield value to ensure structure packing danielgutson@googlemail.com - 2013-11-26 17:19 -0800
csiph-web