[petsc-dev] When __FUNCT__ is wrong

Jed Brown jed at 59A2.org
Fri Aug 27 11:59:32 CDT 2010


C99 mandates __func__, but unfortunately C++ and earlier C standards
mandate no such thing.  Even so, most compilers support __FUNCTION__,
__PRETTY_FUNCTION__ (distinct in C++), or __func__.  Inaccurate traces
annoy me greatly and it's inevitable that __FUNCT__ is occasionally
incorrect.  It also seems a shame for traces to just say "USER provided
function" when the compiler supports something better.  So how about
having configure check for the existance of a compiler-supported name,
and perhaps also add an assertion to PetscFunctionBegin to error if
__FUNCT__ does not match __FUNCTION__ (and is defined to something other
than "User provided function", so that this wouldn't break user code
that ignores __FUNCT__ entirely).

Jed



More information about the petsc-dev mailing list