<div dir="ltr">On Wed, Feb 6, 2013 at 11:12 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On Wed, Feb 6, 2013 at 10:07 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
<br>
  While I'm busy converting macro functions to C functions, others (unnamed, but Jed knows how to find them using the revision control system) are adding new ones like there is no tomorrow.<br>
<br>
For example below.<br>
<br>
Yes CPP is unfairly useful and some of the uses below do pass types that cannot trivially be handled with pure C code, please try to restrict your love of CPP to only when absolutely necessary; for example the first one below doesn't need to be a macro I think.<br>

</blockquote><div><br></div></div><div>The first example below was added by Barry in 2008 and can soon be deleted.</div><div><br></div><div><a href="https://bitbucket.org/petsc/petsc-dev/commits/2c4d80a83ccb656c1ab09c5dcec9c685c121655f" target="_blank">https://bitbucket.org/petsc/petsc-dev/commits/2c4d80a83ccb656c1ab09c5dcec9c685c121655f</a></div>
</div></div></div></blockquote><div><br></div><div style>Programming languages corrupt. Fortran corrupts absolutely.</div><div style><br></div><div style>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>The second is like PetscTryMethod in that it really needs to be a macro.</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


   Barry<br>
<br>
/*<br>
      Allocates enough space to store Fortran function pointers in PETSc object<br>
   that are needed by the Fortran interface.<br>
*/<br>
#define PetscObjectAllocateFortranPointers(obj,N) do {                  \<br>
    if (!((PetscObject)(obj))->fortran_func_pointers) {                 \<br>
      *ierr = PetscMalloc((N)*sizeof(void(*)(void)),&((PetscObject)(obj))->fortran_func_pointers);if (*ierr) return; \<br>
      *ierr = PetscMemzero(((PetscObject)(obj))->fortran_func_pointers,(N)*sizeof(void(*)(void)));if (*ierr) return; \<br>
      ((PetscObject)obj)->num_fortran_func_pointers = (N);              \<br>
    }                                                                   \<br>
  } while (0)<br>
<br>
/* Entire function body, _ctx is a "special" variable that can be passed along */<br>
#define PetscObjectUseFortranCallback_Private(obj,cid,types,args,cbclass) { \<br>
    PetscErrorCode ierr;                                                \<br>
    void (PETSC_STDCALL *func) types,*_ctx;                             \<br>
    PetscFunctionBegin;                                                 \<br>
    ierr = PetscObjectGetFortranCallback((PetscObject)(obj),(cbclass),(cid),(PetscVoidFunction*)&func,&_ctx);CHKERRQ(ierr); \<br>
    (*func)args;CHKERRQ(ierr);                                          \<br>
    PetscFunctionReturn(0);                                             \<br>
  }<br>
#define PetscObjectUseFortranCallback(obj,cid,types,args) PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_CLASS)<br>
#define PetscObjectUseFortranCallbackSubType(obj,cid,types,args) PetscObjectUseFortranCallback_Private(obj,cid,types,args,PETSC_FORTRAN_CALLBACK_SUBTYPE)<br>
<br>
</blockquote></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener
</div></div>