Sujet : Re: "A diagram of C23 basic types"
De : tr.17687 (at) *nospam* z991.linuxsc.com (Tim Rentsch)
Groupes : comp.lang.cDate : 30. Apr 2025, 16:37:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <8634dp8xt9.fsf@linuxsc.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
antispam@fricas.org (Waldek Hebisch) writes:
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>
Kaz Kylheku <643-408-1753@kylheku.com> writes:
>
[some symbols are defined in more than one header]
>
(In my opinion, things would be better if headers were not allowed
to behave as if they include other headers, or provide identifiers
also given in other heards. Not in ISO C, and not in POSIX.
Every identifier should be declared in exactly one home header,
and no other header should provide that definition. [...])
>
Not always practical. A good example is the type size_t. If a
function takes an argument of type size_t, then the symbol size_t
should be defined, no matter which header the function is being
declared in.
>
Why?
Because, in many cases or most cases, when a particular interface is
used, there will be a need to declare variables of a type used in the
interface (either a parameter type or the return type), or to use
such types in other ways (casting, for example). Not defining those
type names makes more work for the client.
One can use a type without a name for such type.
What you mean is it's possible to produce values of such types
without needing to use the name of the type. In some cases that's
true, but often there are other needs that are not addressed by
that possibility, as mentioned in the last paragraph. Furthermore
it doesn't cover cases of derived types, such as size_t *.
Similarly for NULL for any function that has defined
behavior on some cases of arguments that include NULL.
>
Why? There are many ways to produce null pointers.
The macro NULL is used for purposes of documentation. Of course a
simple 0 (perhaps casted to an appropriate type) could be used
instead, but that defeats the purpose of using NULL.
And fact that
a function had defined behavior for null pointers does not mean
that users will need null pointers.
No guarantee, but there is a reasonable likelihood. It's more
convenient for the client if such things are always provided.
No doubt
there are other compelling examples.
>
Do not look compelling at all.
Clearly the people who wrote the ISO C standard feel differently.
I agree with their judgment. And I haven't seen any argument
that a different judgment should prevail, not counting the silly
circular argument offered by another poster.