[petsc-dev] PetscCheck__FUNCT__ and PETSC_FUNCTION_NAME

Jed Brown jed at 59A2.org
Thu Oct 7 14:26:11 CDT 2010

On Thu, Oct 7, 2010 at 21:15, Blaise Bourdin <bourdin at lsu.edu> wrote:

> Hi,
> As of changeset 16818, it looks like PetscFunctionBegin checks for
> consistency of PETSC_FUNCTION_NAME (which is set in
> $PETSC_ARCH/include/petscconf.h to __func__ ) and __FUNCT__, which is user
> set
> This is a problem when __FUNCT__ as been set purposely (or not) to not
> match __func__
> Tao, for instance does a lot of
> #undef __FUNCT__
> #define __FUNCT__ "TaoVecPetsc::Clone"
> int TaoVecPetsc::Clone(TaoVec**ntv){
> In thus, case __func__ (and hence PETSC_FUNCTION_NAME ) is Clone, and
> PetscCheck__FUNCT__ complains (I only checked with the intel compilers on
> mac OS).

That's expected, and __PRETTY_FUNCTION__ (which is not standard) includes
all the types, so it wouldn't match either.  A partial fix would be to just
waive the check if __FUNCT__ contains "::", but then you would still see the
non-namespaced version (because __func__ takes precedence if configure finds
it).  I vote for just turning it off for C++ builds of PETSc.

> Would it be possible to relax PetscCheck__FUNCT__ or to have
> PETSC_FUNCTION_NAME set to __func__ only if __FUNCT__ is not defined?

__FUNCT__ is defined to "User provided function" in the headers, and it
would have to be defined at any PetscFunctionBegin if the compiler did not
support __func__ or similar. The problem with turning off the check
completely is that inconsistency creeps in and then we see wrong stack
traces.  Also, it's really nice for users to not have to write all the
__FUNCT__ stuff and still get correct traces for errors and -malloc_dump.

> If petsc is using PETSC_FUNCTION_NAME everywhere, do we even need
> __FUNCT__?

__func__ was not standardized until C99, nothing is standard in C++, and
idiot Microsoft still hasn't even partially added C99 support (maybe moot, I
don't know if PETSc builds with Visual Studio at the moment).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20101007/4b6ed5a3/attachment.html>

More information about the petsc-dev mailing list