| Deutsch English Français Italiano |
|
<vslfe6$28l7$5@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: "A diagram of C23 basic types" Date: Thu, 3 Apr 2025 10:04:22 +0200 Organization: A noiseless patient Spider Lines: 50 Message-ID: <vslfe6$28l7$5@dont-email.me> References: <87y0wjaysg.fsf@gmail.com> <vsj1m8$1f8h2$1@dont-email.me> <vsj2l9$1j0as$1@dont-email.me> <vsjef3$1u4nk$1@dont-email.me> <vsjg6t$20pdb$1@dont-email.me> <vsjjd1$23ukt$1@dont-email.me> <vsjkvb$25mtg$1@dont-email.me> <vsjlkq$230a5$2@dont-email.me> <vsjs5k$2bfc5$2@dont-email.me> <vsjvgu$2fpp1$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 03 Apr 2025 10:04:23 +0200 (CEST) Injection-Info: dont-email.me; posting-host="d65639e364606db0746acbec737df138"; logging-data="74407"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wXq6KBA1g+xAx0luEUgmBVFeRQJU349Y=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:YWeS9dEgnIscY1kefyC9tv6RA4M= In-Reply-To: <vsjvgu$2fpp1$1@dont-email.me> Content-Language: en-GB Bytes: 3095 On 02/04/2025 20:26, bart wrote: > On 02/04/2025 18:29, David Brown wrote: >> On 02/04/2025 17:38, bart wrote: >>> On 02/04/2025 16:26, Muttley@DastardlyHQ.org wrote: > >>>> Never understood that in C++ never mind C. NULL has worked fine for >>>> 50 years. >>> >>> And it's been a hack for 50 years. Especially when it is just: >>> >>> #define NULL 0 >> >> >> The common definition in C is : >> >> #define NULL ((void*) 0) >> >> Some compilers might have an extension, such as gcc's "__null", that >> are used instead to allow better static error checking. >> >> (In C++, it is often defined to 0, because the rules for implicit >> conversions from void* are different in C++.) >> >>> >>> You also need to include some header (which one?) in order to use it. >> >> <stddef.h>, as pretty much any C programmer will know. > > This program: > > void* p = NULL; > > reports that NULL is undefined, but that can be fixed by including any > of stdio.h, stdlib.h or string.h. Those are the first three I tried; > there may be others. > > 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. > Fair enough - it is correct that there are some other standard headers that also define NULL (and/or a few other common identifiers such as size_t or wchar_t). The standard source of these common definitions, without pulling in a range of other identifiers, is <stddef.h>. (That is where it is documented in the standards.) It doesn't matter to C programmers /where/ NULL is defined, or how - it matters merely that it is defined when they need it, and what it means.