Sujet : Re: "A diagram of C23 basic types"
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.cDate : 07. Apr 2025, 19:31:03
Autres entêtes
Organisation : To protect and to server
Message-ID : <vt15l5$3e57a$1@paganini.bofh.team>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
Keith Thompson <Keith.S.Thompson+
u@gmail.com> wrote:
antispam@fricas.org (Waldek Hebisch) writes:
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
[...]
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? One can use a type without a name for such type.
Convenience and existing practice. Sure, an implementation of
<string.h> could provide a declaration of memcpy() without making
size_t visible, but what would be the point?
Cleanliness of definitions? Consistency? Fragment that you
replaced by [...] contained a proposal:
Every identifier should be declared in exactly one home header,
and no other header should provide that definition.
That would be pretty clean and consistent rule: if you need some
standard symbol, then you should include corresponding header.
Tim claimed that this in not practical. Clearly C standard changed
previous practice about headers, so existing practice is _not_
a practical problem with adapting such proposal. With current
standard and practice one frequently needs symbols from several
headers, so "convenience" is also not a practival problem with
such proposal. People not interested in clean name space can
define private "all.h" which includes all standard C headers
and possibly other things that they need, so for them overhead
is close to zero.
-- Waldek Hebisch