C++ definition of NULL
Gabriel Dos Reis
Gabriel.Dos-Reis@dptmaths.ens-cachan.fr
Tue Mar 2 21:41:00 GMT 1999
>>>>> Chad Gatesman <chadg@redrose.net> wrote:
> Jason Merrill wrote:
>> > I am currently porting a very large library that depends on the passing
>> > of NULL into parameters declared as long int.
>>
>> > egcs appears to define NULL as __null which is a builtin symbol that
>> > treats NULL as `{unknown type} *'. Therefore, I cannot pass in NULL to
>> > a long int parameter without casting it.
>>
>> Why would you want to? Conceptually, NULL is a pointer value.
> I see what you are saying, but unfortunately, this is not my code. I am
> mearly porting it. And, technically, it should work since the standard says
> NULL should be a 0 or 0L
^^^^^^^^
No. The C++ Standard does not say anything like that. The exact
wording is:
18.1/4
---
The macro NULL is an implementation-defined C++ null pointer
constant in this Internnational Standard (4.10).
---
Footnote says:
---
Possible definitions include 0 and OL, but not (void*)0.
---
Please notice that integer type is not limited to int or long int. It
includes bool, char, short, ...
But I agree with you that the compiler should have selected
func(long) is NULL is of integer type.
-- Gaby
More information about the Gcc
mailing list