[petsc-dev] PetscCheck__FUNCT__ and PETSC_FUNCTION_NAME

Jed Brown jed at 59A2.org
Thu Oct 7 15:46:07 CDT 2010


On Thu, Oct 7, 2010 at 22:28, Satish Balay <balay at mcs.anl.gov> wrote:

> Another way of dealing with this [was discussing with Jason about it]
> - is to split of the names into 2 macros.
>
> #define __CLASS__ TaoVecPetsc [or TaoVecPetsc::]
>
> #define __FUNCT__ Clone
>
> So - somehow the petsc macros print out the same info Jason would like
> [TaoVecPetsc::Clone] - but internally - the check of __func__ vs
> __FUNCT__ is still done [but not the __CLASS__ part]
>

Hmm, the macro cannot determine whether __CLASS__ is defined, so it would
have to be defined everywhere.  Also, __func__ is as if the function had

static const char __func__[] = "FunctionName";

immediately after the opening brace.  This means that it is not a string
literal and thus cannot be concatenated by the preprocessor as in

#define PETSC_FUNCTION_NAME __CLASS__ "::" __func__

One option would be to have PETSC_FUNCTION_NAME defined to __FUNCT__ and
PetscCheck__FUNCT__ could only compare the part after the last "::".  The
problem here is that user code does not reap any benefits unless they put

#undef __FUNCT__
#define __FUNCT__ "FunctionName"

in front of all of their functions.

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


More information about the petsc-dev mailing list