<div class="gmail_quote">On Wed, Nov 9, 2011 at 14:51, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@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=":2yx"> In C we could do #define PETSC_NULL ((void*) 0) and every thing would be fine<br></div></blockquote><div><br></div><div>yes</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div id=":2yx">
<br>
In C++ this won't work and there is no alternative except a standard that is 2 months old (but for those programming in C++ this is not really a problem because there is really no need for varargs in proper C++ code).<br>
</div></blockquote><div><br></div><div>unless they want to call our variadic functions</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":2yx">
<br>
Questions:<br>
1) Why won't it work in C++? Note that PETSC_NULL truly is suppose to always be used as a null pointer and should never be used as 0; if int 0 is intended then int 0 should be used.<br></div></blockquote><div><br>
</div><div>C++ needs an explicit cast to convert from void*. So</div><div><br></div><div>some_type *x = (void*)0;</div><div><br></div><div>is a compilation error. It's too much to ask for an explicit cast any time PETSC_NULL is passed.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div id=":2yx">
<br>
2) Can we at least fix it for C by using #define PETSC_NULL ((void*) 0) in C and using 0 in C++. After all nobody really uses PETSc from C++ :-)</div></blockquote></div><br><div>This will work. They should be able to pass nullptr in C++11, NULL with GCC and some other compilers, or (void*)0 only in variadic slots (because those types aren't checked by the compiler).</div>