Sujet : Re: Suggested method for returning a string from a C program?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 21. Mar 2025, 00:10:33
Autres entêtes
Organisation : None to speak of
Message-ID : <87iko3s3h2.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : Gnus/5.13 (Gnus v5.13)
bart <
bc@freeuk.com> writes:
On 20/03/2025 18:46, Michael S wrote:
On Thu, 20 Mar 2025 15:40:20 +0000
bart <bc@freeuk.com> wrote:
Pretty much every other open source project I look likes to define
their own types!
>
So I have to ask, why do think they do that?
>
Most likely mindless parroting of 40 y.o. examples.
>
I don't think so. Where such sets of types exist, they tend to be
defined on top of long long too, or even on top of stdint.h types.
If they're defined on type of <stdint.h> types, it's likely because the
definitions were updated (just referring to int32_t is easier than a
nest of #ifdefs) while keeping the existing type names and avoiding
breaking existing code that depends on them.
Look at this one for example:
>
typedef uint8_t byte; // from arduino.h
>
I can only one of reason this exists, which is that 'byte' is a far
nicer denotation.
I agree in this case. "byte" documents what the type is intended for.
It's not uncommon to do something like `typedef unsigned char byte;`,
and I've done it myself, but I'm more likely to use `unsigned char`
directly and just keep in mind that it is by definition one byte.
But "GLuint" doesn't tell me anything that "unsigned int" didn't already
tell me. I suspect that exists just because OpenGL (which I haven't
looked at lately) defines a number of its own types, and it was more
consistent to give them all GL prefixes.
You might also consider why such examples existed even 40 years ago.
They existed 40 years ago because <stdint.h> didn't exist yet. For that
matter, C90 didn't exist yet. (I have some difficulty accepting that
1985 was 40 years ago.)
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */