Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: What is the data structure of a NULL? Date: Sat, 28 Dec 2019 13:22:46 -0800 Organization: None to speak of Lines: 33 Message-ID: <87o8vsqh5l.fsf@nosuchdomain.example.com> References: <87sgl4rc3w.fsf@nosuchdomain.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="8d88aa08a0f2992ca9bb73f0d3f59382"; logging-data="10896"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+STlOJaGPGGr+BOX+oqfKH" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:WYXj/9JC7R092p4tQFou9M0exNY= sha1:RxL763ZA4iScllQn1KVLf/8RoWg= Xref: csiph.com comp.lang.c++:70744 Ned Latham writes: > Keith Thompson wrote: >> T writes: >> > >> > In C++, when you make a call to Windows Kernel32.dll >> > and it wants a NULL for one or more of its parameters, >> > what exactly is the structure of a NULL? A 32 bit >> > word full of zeros? >> >> You might get better answers if you explained why you want to know. >> >> If you're making a call from C++, you can just pass a null pointer >> value such as nullptr or NULL. The compiler needs to know how >> it's represented. You probably don't. > > But knowing it can be useful, I use (void*) to cast integers and > unsigned integers for functions that require pointer parameters, > and if (parm) to test them. Why? Can you share some examples? If a function takes a pointer parameter, you need to pass a pointer value to it. There are cases where it might make sense to cast an integer to void*, but they're rare. If you need to pass a null pointer, use nullptr or NULL. (In some low-level code, you might store pointer values in integers.) As for `if (parm)`, that's valid for any scalar type. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com [Note updated email address] Working, but not speaking, for Philips Healthcare void Void(void) { Void(); } /* The recursive call of the void */