[petsc-dev] Arguments that are logically void**

Barry Smith bsmith at mcs.anl.gov
Mon Jun 6 14:14:13 CDT 2011

On Jun 6, 2011, at 1:45 PM, Jed Brown wrote:

> On Mon, Jun 6, 2011 at 20:34, Kai Germaschewski <kai.germaschewski at unh.edu> wrote:
> Wouldn't it make sense to  have DMDAVecGetArray[23]d() and have the argument be PetscScalar ***, and PetscScalar ****, respectively? That would actually check that one passes in a reference to the right type, making it both safe and avoid the need for casting? That's also more in line with, e.g., VecGetArray2d().
> The field type is often not PetscScalar (it's a struct containing several PetscScalar members) so you would need the cast anyway. The cast is also very complicated if you're going to make the interface const-correct.
> I'm not sure where else void ** is used, and whether similar solutions would apply. In general, I agree with Jed that I'd rather not have the explicit cast in the user code.
> I was thinking of SNESGetApplicationContext() and similar. There are a few places where the user registers a context and may also have to get it out.

   I agree with Jed's suggestion and updated the developers guide to indicate that these routine should have the argument type void *.


More information about the petsc-dev mailing list