Sujet : Re: "A diagram of C23 basic types"
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 02. Apr 2025, 19:51:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250402113624.693@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-02, bart <
bc@freeuk.com> wrote:
So it is not true that you need include stddef.h, nor obvious that that
is where NULL is defined, if you are used to having it available indirectly.
It's documented as the canonical source of NULL.
In C90, now 35 years ago, it was written up like this:
7.1.6 Common definitions <stddef.h>
The following types and macros are defined in the standard header
<stddef.h>. Some are also defined in other headers, as noted in their
respective subclauses.
...
The macros are
NULL
which expands to an implementation-defined null pointer constant: and
offsetof(type, member-designator)
... etc
There is no other easy way to find that out. An implementation could directly
stick #define NULL into every header that is either allowed or required to
reveal that macro, and so from that you would not know which headers are
required to provide it.
Many things are not going to be "obvious" if you don't use documentation.
(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.
Programs ported from one Unix to another sometimes break for no other reason
than this! On the original platform, a header provided a certain identifier
which it is not required to; on the new platform that same header doesn't do
that.)
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca