[petsc-dev] removing PETSC_NULL from petsc-dev
Jed Brown
jedbrown at mcs.anl.gov
Wed Feb 13 10:58:12 CST 2013
On Wed, Feb 13, 2013 at 7:29 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> > I have removed the use of PETSC_NULL from all PETSc C code. Please
> remember to just use NULL in PETSc source code in the future (or Karl's
> script will find you).
> >
> > I see you changed to
> >
> > #define PETSC_IGNORE NULL
> >
> > but kept
> >
> > #define PETSC_NULL 0
> >
> > Should the second be updated to
> >
> > #define PETSC_NULL NULL
> >
> > because it is stricter about passing PETSC_NULL for an integer argument?
>
> Yes, I was hesitant to change too much at once. It is fine to change and
> fine to add the damn deprecated message.
Sadly, this hack does not work because according to C++, the comma-sequence
'(x,0)' yields a different type from '0'. In particular, the latter can be
implicitly converted to a pointer type, but the former cannot. AFAIK, the
only way to do this is to use 'nullptr'. Consequently, we can update to
'#define PETSC_NULL NULL', but cannot include a deprecated message. I also
think I was perhaps a little overzealous about deprecation. It doesn't
cause any hardship for it to exist as long as we don't refer to it any
where, thus there may be no reason to break user code by removing
PETSC_NULL. Since people are inherently a bit lazy, I think its use will
quietly go away.
https://bitbucket.org/petsc/petsc-dev/commits/77e0b4525183a96d1d7836ee30256fe1949ca489
This will cause warnings at those places where PETSC_NULL was used in place
of an int, but people should update those anyway because it's confusing.
Note that we still cannot _depend_ on NULL having "pointer" type, for
example, when passed to a variadic function. (We had a thread about that a
while back.) It's perfectly valid for stddef.h to '#define NULL 0'.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130213/36a0436d/attachment.html>
More information about the petsc-dev
mailing list