From: Philipp K. K. <pk...@sp...> - 2010-01-22 12:05:48
|
Third attempt (this time via another SMTP server, and I finally remember that the admin mentioned something about server maintenance today). -------- Original Message -------- Subject: [Fwd: Re: [sdcc-devel] Separate _Bool from bit?] Date: Fri, 22 Jan 2010 12:54:13 +0100 From: Philipp Klaus Krause <pk...@sp...> To: Development chatter about sdcc <sdc...@li...> Another lost message: -------- Original Message -------- Subject: Re: [sdcc-devel] Separate _Bool from bit? Date: Fri, 22 Jan 2010 12:27:40 +0100 From: Philipp Klaus Krause <pk...@sp...> To: Development chatter about sdcc <sdc...@li...> References: <4B5...@sp...> <3ff...@ma...> <4B5...@si...> <4B5...@si...> Borut Razem wrote: > I have to explain my statement: I was thinking and writing what is > possible to do for sdcc 3.0 release, so "not applicable" should be read > as "not feasible for 3.0 release". > > Jan is absolutely right: bit addressing is possible and many compilers > are already using it. Usually it is implemented as (<byte address> * 8 + > <bit position in byte>). Actually also the mcs51 sdcc target is using it > internally. Unfortunately I do not know as much about C as I wish I would, so I have to go through the standard searching for things that might clarify the situation and ask the list about them. So on one hand we have 1119 The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. 1120 The size is determined from the type of the operand. 1121 The result is an integer. Thus sizeof(_Bool) >= 1. and 571 Values stored in unsigned bit-fields and objects of type unsigned char shall be represented using a pure binary notation.40) 572 Values stored in non-bit-field objects of any other object type consist of n × CHAR_BIT bits, where n is the size of an object of that type, in bytes. and 305 Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign. 306 14) See “future language directions” (6.11.3). 307 — number of bits for smallest object that is not a bit-field (byte) CHAR_BIT 8 This looks like the standard _requires_ at least 8 bits per _Bool. On the other hand bit-addressable memory seems to be a way to make using just one bit per _Bool transparent to the user. Philipp P.S.: IMO C should remove the sizeof(char) == 1 requirement. It would solve multiple issues with odd archtiectures. However in sdcc we should aim for standard compliance. |