<div class="gmail_quote">On Wed, Nov 9, 2011 at 15:15, Satish Balay <span dir="ltr"><<a href="mailto:balay@mcs.anl.gov">balay@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":34k"><petscsys.h><br>
extern void* PETSC_NULL<br>
<init.c><br>
static void* PETSC_NULL=0L [or null or nullptr - based on configure determined flags]<br></div></blockquote><div><br></div><div>You must not really mean "static".</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":34k">
<br>
[so as to avoid language/functionality based #def() code in petscsys.h<br>
- that could potentially cause issues like what we had with isinf()<br>
stuff]</div></blockquote></div><br><div>The problem is that C++ does not allow implicit conversion from void* to a different pointer type. Note how PetscMalloc needs an explicit cast. It is not possible to write</div><div>
<br></div><div>int *x = malloc(sizeof(int));</div><div><br></div><div>in C++, you need</div><div><br></div><div>int *x = (int*)malloc(sizeof(int));</div><div><br></div><div>If we unconditionally define PETSC_NULL to be (void*)0, then we cannot avoid requiring the user to make that cast all over the place.</div>