[petsc-dev] macro wrappers around functions to caste suck

Jed Brown jedbrown at mcs.anl.gov
Fri Apr 5 19:50:12 CDT 2013


On Fri, Apr 5, 2013 at 7:40 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

> (lldb) b PetscFunctionListAdd
> Breakpoint 4: no locations (pending).
> WARNING:  Unable to resolve breakpoint to any actual locations.
> (lldb) b PetscFunctionListAdd_Private
> Breakpoint 5: where = libpetsc.dylib`PetscFunctionListAdd_Private + 23 at
> reg.c:173, address = 0x000000010a1d3697
>

The solution to too many macros is always MOAR MACROS!

This is valid:

PETSC_EXTERN PetscErrorCode PetscFunctionListAdd(PetscFunctionList*,const
char[],void (*)(void));
#define PetscFunctionListAdd(list,name,fptr)
PetscFunctionListAdd((list),(name),(PetscVoidFunction)(fptr))


off in the implementation:

#undef PetscFunctionListAdd
PETSC_EXTERN PetscErrorCode PetscFunctionListAdd(PetscFunctionList
*fl,const char name[],void (*fnc)(void))
{
  ...
}


This would make the debugging thing work, at the expense of being slightly
more confusing to the reader. But maybe comments would be enough to explain
what's going on?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20130405/3416fddd/attachment.html>


More information about the petsc-dev mailing list