Re: [petsc-dev] removing PETSC_NULL from petsc-dev
On Thu, Feb 7, 2013 at 9:56 PM, Barry Smith <[email protected]> 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? Also, we could do something like this (properly guarded, of course): __attribute__((deprecated)) PETSC_UNUSED PETSC_STATIC_INLINE void PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL() {}; #define PETSC_NULL (PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL(),NULL) which can be used for any compiler that supports non-static statements in declarations (everything but Sun and MSVC?) and has __attribute__((deprecated)). This produces warnings like this under Clang ex5.c:102:36: warning: 'PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL' is deprecated [-Wdeprecated-declarations] ierr = PetscOptionsGetReal(PETSC_NULL,"-par",&user.param,NULL);CHKERRQ(ierr); ^ /home/jed/petsc/include/petscsys.h:387:31: note: expanded from macro 'PETSC_NULL' #define PETSC_NULL (PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL(),NULL) ^ /home/jed/petsc/include/petscsys.h:385:33: note: 'PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL' declared here PETSC_UNUSED static inline void PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL() {}; ^ 1 warning generated. and like this with GCC: ex5.c: In function ‘main’: ex5.c:102:3: warning: ‘PETSC_NULL_IS_DEPRECATED_JUST_USE_NULL’ is deprecated (declared at /home/jed/petsc/include/petscsys.h:385) [-Wdeprecated-declarations] We can make the error message cleaner (but more confusing) with __attribute__((deprecated)) PETSC_UNUSED static inline void PETSC_NULL() {}; #define PETSC_NULL (PETSC_NULL(),NULL) which produces: ex5.c: In function ‘main’: ex5.c:102:3: warning: ‘PETSC_NULL’ is deprecated (declared at /home/jed/petsc/include/petscsys.h:385) [-Wdeprecated-declarations] Any sense in this stuff?
participants (1)
-
Jed Brown