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

Jed Brown jed at 59A2.org
Mon Jun 6 13:20:48 CDT 2011


On Mon, Jun 6, 2011 at 20:00, Barry Smith <bsmith at mcs.anl.gov> wrote:

> So is the only benefit that one does not need the extra characters (void**)
> in front of the argument?
>

Yes.

Rationale.

The use of a formal parameter attribute_val or type void* (rather than
void**) avoids the messy type casting that would be needed if the attribute
value is declared with a type other than void*. ( End of rationale.)


>
>   Doesn't seem like much of a benefit? At this point I think doing it
> either way is fine but if we are inconsistent we should fix some of them to
> be consistent. I am leaning to vote for the (void**) approach; it is clearer
> when one looks at code.
>

I think the cast is ugly if it appears in places that should not be "scary".
For example, I think DMDAVecGetArray(da,X,&x) is significantly nicer than
DMDAVecGetArray(da,X,(void**)&x).

Needing an explicit cast makes the reader think about the safety of the
cast. This is a good thing for calls that should look a bit scary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110606/012c4d2e/attachment.html>


More information about the petsc-dev mailing list