Article View: comp.std.c
Article #4863Re: Bit-field sizes
From: Larry Jones
Date: Thu, 07 Mar 1996 16:42
Date: Thu, 07 Mar 1996 16:42
26 lines
1844 bytes
1844 bytes
In article <4hkgds$bbh@info1.sdrc.com>, I wrote (quoting the standard): > > The expression that specifies the width of a bit-field shall be > an integral constant expression that nas nonnegative value that > shall not exceed the number of bits in an ordinary object of > compatible type. In article <uYgPxQ9ytt9W084yn@csn.net>, thads@csn.net (Thad Smith) writes: > What does "ordinary object of compatible type" mean? Could that mean > long? I now think that an implementation could allow specification of > a number of bits greater than int, but less than or equal to bits in > long. To access the value, the programmer casts the bit-field to long > or unsigned long. The cast would preceed the integral promotion, I > think, and allow access to the longer value. An ordinary object (i.e., not a bit-field) with the same type as the declared type of the bit-field which is required to be int, signed int, or unsigned int. As Norm Diamond pointed out, that requirement is in semantics, not constraints, so an implementation is free to add an extension allowing other types (like long), and some do. Such implementations presumably extend the integral promotion rules in the obvious fashion as well in order to eliminate the need for casts. ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com Santa's gonna skip this block for years. -- Calvin
Technical Details
Message-ID:
<4hn3mg$c9v@info1.sdrc.com>Path:
arc1-ca.pugleaf.net!sdrc.com!thor!scjonesReferences:
<nzRPxQ9ytZZA084yn@csn.net> <4hkgds$bbh@info1.sdrc.com> <uYgPxQ9ytt9W084yn@csn.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sdrc.com!thor!scjones From: larry.jones@sdrc.com (Larry Jones) Newsgroups: comp.std.c Subject: Re: Bit-field sizes Date: 7 Mar 1996 16:42:56 GMT Organization: SDRC Engineering Services Distribution: world Message-ID: <4hn3mg$c9v@info1.sdrc.com> References: <nzRPxQ9ytZZA084yn@csn.net> <4hkgds$bbh@info1.sdrc.com> <uYgPxQ9ytt9W084yn@csn.net> NNTP-Posting-Host: thor.sdrc.com Originator: scjones@thor