Richard Heathfield said:
Kelsey Bjarnason a écrit :
Topicality is essential to Usenet's users. I know that you
don't understand this. Destruction of personalities is not
topical here, so please do it in a newsgroup where it is
topical.
My answer was on topic. The user asked how he could use 128 bit
numbers in C. I answered that my compiler provides native
support for 128 bit numbers.
And, of course, your compiler defines C, right? After all, the
question was how to do it _in C_, not in _Jacob Navia's pet
compiler_. Unless the two are synonymous, your answer would have
been wholly irrelevant.
The C standard Appendix J.5:
Common extensions
the bit you missed [I quote from the ANSI 89 standard, I assume
similar
wording in C99]
[snip]
[errors in transcription are mine]
My copy reads: "The following extensions are widely used in many
systems, but are not portable to all implementations. The inclusion
of any extension that may cause a strictly conforming program to
become invalid renders an implementation nonconforming. Examples of
such extensions are new keywords, or library functions declared in
standard headers or predefined macros with names that do not begin
with an underscore."
[...]
I've been curious about just how lcc-win implements 128-bit integers,
particularly whether they're implemented as an extension that doesn't
violate the C99 standard. I don't currently have a system on which
I can install it, so I resorted to Google and found the following:
In <
http://www.q-software-solutions.de/products/lcc-win32/changelog.shtml>:
128 bit integers are now possible. To use them #include <i128.h>.
The library is i128.lib.
(Incidentally, I had to view the HTML source to read that; the '<' and
'>' characters need to be converted to be read properly in
an ordinary browser window.)
And at
<
http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2008-04/msg04961.html>,
apparently somebody's archive of his newsgroup, in an article posted
in April 2008:
P.S. This feature is now native in the 64 bit version, i.e.
not using operator overloading as in the 32 bit version.
The good news is that if the feature isn't enabled until you add
"#include <i128.h>", then it doesn't break any strictly conforming
code.
The not quite as good news is that, at least in the 32-bit version
of lcc-win, it's apparently not implemented using "extended integer
types" as described in C99 6.2.5.
I would like to encourage *some* implementer to provide
128-bit integers using this mechanism. This would mean that no
system-specific header would be required, that intmax_t and uintmax_t
would be 128-bit types, also defined as {,u}int128{,fast,least}_t,
and that *portable* code could potentially use 128-bit arithmetic.
In general, I don't know of *any* C compilers that provide extended
integer types as defined in C99 6.2.5 -- but I'm certainly not
familiar with all C compilers.
This is not (necessarily) a criticism of the way lcc-win currently
does this. Providing it as a non-portable extension is probably
a good start.
(Possibly the 64-bit version of lcc-win already does this, but I
haven't found enough information to confirm that.)