On Wed, Nov 9, 2011 at 9:19 PM, Jed Brown <span dir="ltr"><<a href="mailto:jedbrown@mcs.anl.gov">jedbrown@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div class="im">On Wed, Nov 9, 2011 at 15:15, Satish Balay <span dir="ltr"><<a href="mailto:balay@mcs.anl.gov" target="_blank">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><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><div>You must not really mean "static".</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>
<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></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>

</blockquote></div><br>So the problem is that in C++, when using a variadic function, you cannot type PETSC_NULL directly into the argument list? When would you ever<div>do this? If an argument to Printf() is equal to PETSC_NULL, no problem. Its only when PETSC_NULL is passed directly. Why not prevent that in</div>
<div>all PETSc variadic functions, which I think are only the prints.</div><div><br></div><div>   Matt<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<br>
</div>