Sujet : Re: Loops (was Re: do { quit; } else { })
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 17. Apr 2025, 20:55:31
Autres entêtes
Organisation : None to speak of
Message-ID : <87fri6pnpo.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
On 17/04/2025 19:47, Keith Thompson wrote:
bart <bc@freeuk.com> writes:
>
Or maybe you can tell me where I can buy a computer (not some board
with an embedded microcontroller) where a C compiler for it has an
'int' type other than 32 bits (with either fewer bits, or more!).
Not the point. It's about what "int" *means*. It doesn't mean "a
32-bit integer".
At present it only seems to bother you. Since if it REALLY bothered
anyone here, nobody would be using 'int'; they'd be using int32_t or
long, unless they're happy that their int values and intermediate
calculations would be using only 16 bits.
POSIX and Windows both guarantee that int is at least 32 bits wide,
and
it's perfectly reasonable to rely on those guarantees on those platforms.
It would be so easy for you to get this right, but you don't even
acknowledge the possibility that I might have a valid point.
>
It's an obscure, pedantic point.
I'd say that I disagree, but I don't feel the need to make the same
point repeatedly.
A better one is that if considering only Windows and POSIX (what about
MacOS or Android?), then you admit int will be 32 bits (at least, but
I'm not holding my breath for 64).
MacOS and Android are both POSIX-based systems.
That means that if either of those OSes are implied, then we can
assume that 'int' means a 32-byte to near 100% likelihood.
In this context, neither of those OSes was implied. The discussion was
about the semantics of for loops, applicable to all C implementations
(and all implementations of the other languages that crept into the
discussion).
And POSIX requires int to be *at least* 32 bits wide, though systems with
int wider than 32 bits are rare.
That saves thousands of posters having to qualify every reference to
'int' with '[on POSIX or Windows]' or 'when it is exactly 32 bits'.
Most references to int do not depend on its width. For contexts where
it does matter, like the remark that has triggered this subthread, you
can just say "32-bit int".
Here's what you wrote upthread:
What's far more useful is that it naturally works with i64 so has
limits 4 billion times bigger than you get with C's default 'int'
type.
Here's what you could have written:
What's far more useful is that it naturally works with i64 so has
limits 4 billion times bigger than you get with 32-bit int.
That's clearer, shorter, and correct, and would have avoided this
entire subthread. I would not have commented on it.
That would be ironic if they have been making that assumption in their
source code for years and decades, where it would be critical, but are
not allowed to do so on long-running Usenet discusssions where it
doesn't really matter.
>
So, like you get tired of my keeping on defending my stances from
attacks on multiple fronts, I get tired of having remember that some
specialised hardware that runs C may have a 16-bit int or something
equally unusual.
All you have to remember is what C says about int.
You already knew that C only requires to be at least 16 bits. I do not
believe for a moment that you weren't aware of that.
In that case, why don't I save time by stating:
>
* Whenever I mention 'int' type in the context of C, it means the
32-bit type
>
* If I intend it to mean anything other than that, I will say so.
Again, if you had just said "32-bit int", there wouldn't have been
a problem.
And again, you refuse to acknowledge that I might have a valid point,
something you've repeatedly demanded from others (and failed to
acknowledge when it actually happens).
"int" is a technical term defined by the C standard. If you
deliberately use it incorrectly, you're going to get some pushback.
It's difficult to avoid the conclusion that that's exactly what
you want.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */