Re: [PATCH] Replace NULL symbol with 0



"Tomasz Kupczyk" <kupczyk tomasz gmail com> a écrit:

> When is NULL not necessarily correct? I suppose it's better to read
> some rationale why nullptr is introduced :)

For instance:

    #define NULL (void*)0

    void foo(const char*);

    void
    bar()
    {
      foo(NULL);
    }

The GNU C compiler compiles this just fine, whereas the GNU C++ compiler
does not, because you can't cast a void* into a char*.

This is a case of a valid C definition of NULL, which is not valid in
C++.

-- 
		Dodji


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]