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

Jed Brown jed at 59A2.org
Mon Jun 6 13:45:01 CDT 2011


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110606/143b3483/attachment.html>


More information about the petsc-dev mailing list