Functional syntax (Was: RE: [mercury-users] Hi, and determini sm)
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Feb 8 15:41:30 AEDT 2001
On 08-Feb-2001, Richard A. O'Keefe <ok at atlas.otago.ac.nz> wrote:
> struct { int a:7, b:5, c:4; } x;
> ...
> In this little example, both packed records would be 32 bits, so
> there would be no space advantage to the tighter packing. (Yes, I know
> there are 16 bits, but most C compilers make records a multiple of 32 bits
> anyway.)
GNU C will make that 16 bits if you use
struct { short a:7, b:5, c:4; } x;
Allowing `short' bitfields is an extension to standard C.
But it's not hard to make such uses conditional, e.g.
#ifdef __GNUC__
typedef short short_bitfield;
#else
typedef int short_bitfield;
#endif
struct { short_bitfield a:7, b:5, c:4; } x;
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list