This is the mail archive of the
mailing list for the GCC project.
Re: Two suggestions for gcc C compiler to extend C language (by WD Smith)
- From: Warren D Smith <warren dot wds at gmail dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 26 Jul 2016 10:55:07 -0400
- Subject: Re: Two suggestions for gcc C compiler to extend C language (by WD Smith)
- Authentication-results: sourceware.org; auth=none
- References: <CAAJP7Y3cHYEOpdhZUXF1PZAJ=vkKoozRiPgwm2V_jH_T63XTKw@mail.gmail.com> <CAH6eHdRrmRWARhbcqWbqV07Y=SZp+Hsiv5-42y2k28CHqP4+UQ@mail.gmail.com> <CAAJP7Y0oRZmE4qS=shs4m7EWjWK2RfZdK2NSe1Kx1ZUT6W=QZw@mail.gmail.com> <alpine.DEB.email@example.com>
On 7/26/16, Joseph Myers <firstname.lastname@example.org> wrote:
> On Tue, 26 Jul 2016, Warren D Smith wrote:
>> (And in the case of uint4_t, it actually would not even BE an
>> "extension" since as I said,
>> the standard already allows providing other sizes.)
> Only sizes which are an integer number of bytes with no padding bits.
"The C99 standard includes definitions of several new integer types to
enhance the portability of programs. The already available basic
integer types were deemed insufficient, because their actual sizes are
implementation defined and may vary across different systems... All
new types are defined in <inttypes.h> header (cinttypes header in C++)
and also are available at <stdint.h> header (cstdint header in C++).
The types can be grouped into the following categories:
* Exact-width integer types which are guaranteed to have the same
number N of bits across all implementations. Included only if it is
available in the implementation..."
This wikipedia page nowhere says it must be an integer number of bytes
with no padding.
And you will notice they *intentionally* chose to name them int8_t
meaning 8 BITs wide, and *not* meaning 8 BYTEs wide, intentionally
choosing those names presumably because they wanted to permit
sizes not a multiple of 8.
And they said "only if available in implementation" which gcc chose to
"we're not going to make other sizes available, hahahaha." But gcc could choose
to get ahead of the other compilers, leading not following, by
making them available. If you were really ambitious you could provide int7_t
etc (w.g. all integer sizes up to 64) but I am not asking for that
level of ambition. I am asking merely for the easy sizes 1, 2 and 4
which you plainly have already written
the code to do, just change some numbers.
You are free to attack the standards bodies as being idiots. But they weren't
being idiots in this decision.