[petsc-dev] removing PETSC_NULL?
Barry Smith
bsmith at mcs.anl.gov
Wed Feb 6 21:58:01 CST 2013
On Feb 6, 2013, at 9:48 PM, Matthew Knepley <knepley at gmail.com> wrote:
> On Wed, Feb 6, 2013 at 9:33 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> 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.
>
> I don't mind removing it, although the Fortran people still have to use something else.
We can leave it as PETSC_NULL_XXXX in Fortran as it is now.
Barry
>
> Matt
>
> --
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener
More information about the petsc-dev
mailing list