[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposal: immediate strings
From: |
Dmitry Antipov |
Subject: |
Re: Proposal: immediate strings |
Date: |
Wed, 06 Jun 2012 11:29:47 +0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 |
On 06/06/2012 10:41 AM, Paul Eggert wrote:
OK, but can't we then simply say 'unsigned int foo : N' where N is the
proper width?
struct foo {
unsigned int x : BITS_PER_PTRDIFF_T - 1;
unsigned y : 1;
};
will work only if sizeof (ptrdiff_t) == sizeof (int); if
sizeof (ptrdiff_t) == sizeof (long) and sizeof (long) > sizeof (int),
(the most of 64-bit environments), compilers will complain about
an invalid bitfield size. For the particular case of gcc, it's
'width of ‘x’ exceeds its type' error.
Note 'unsigned long' bitfield type:
struct foo {
unsigned long x : BITS_PER_PTRDIFF_T - 1;
unsigned y : 1;
}
works even if BITS_PER_PTRDIFF_T < BITS_PER_LONG.
Dmitry