[petsc-dev] removing PETSC_NULL?

Jed Brown jedbrown at mcs.anl.gov
Wed Feb 6 20:33:52 CST 2013


On Wed, Feb 6, 2013 at 7:35 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
>    In 1994 NULL was a pain because for different systems it was in
> different include files and sometimes you had to do very nasty stuff like
>
> #if !defined(NULL)
> #define NULL  0
>
> This is why PETSC_NULL came into existence.
>
> Is the world a different place now? Based on the fact there are numerous
> (272 to be exact thanks to Karl) uses of NULL in PETSc today and they seem
> to cause absolutely no grief? (Except to Barry's tidy little mind) it seems
> PETSC_NULL is not needed any longer?
>
>    If this is the case I propose we eradicate PETSC_NULL replacing it
> everywhere with NULL.
>

We had a similar discussion a while back.

http://lists.mcs.anl.gov/pipermail/petsc-dev/2011-November/006315.html

Using NULL instead of PETSC_NULL does not help to safely pass a null
pointer value to a variadic function, but PETSC_NULL is also unsafe.

Note that nearly all instances of 'NULL' are in either sieve (disabled by
default), examples, or pretty new code. (It's even possible that there were
zero occurrences in critical library back when we had that thread.)
However, there are certainly a few instances now and we've received no
mail, so I'm also in favor of replacing PETSC_NULL with NULL.

It's C89 after all, so as long as we are sure to include stddef.h, we
should be fine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130206/ac7dcebc/attachment.html>


More information about the petsc-dev mailing list