On 9 November 2011 17:51, Barry Smith <bsmith at mcs.anl.gov> wrote: > > ?To summarize: > > ? ?In C we could do #define PETSC_NULL ? ? ? ? ?((void*) 0) and every thing > would be fine >
Yes, or just include stdlib.h and define to NULL. > ? ?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). > No varargs in proper C++ code? What do you mean? What if you have to access a C API (like the one in PETSc) from C++? > ?Questions: > ? ? 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. > Try to cout << sizeof(PETSC_NULL) in a 64 bits machine and you will notice. > ? ? 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++ :-) > actually, we could try to define PETS_NULL as "0" in 32bits and "0L" in 64bits (OS X, Linux)... For WinDog 64, this does not work, I do not remember if there is some way to specify literals for __in64 ... perhaps ((__in64)0) would do... -- Lisandro Dalcin --------------- CIMEC (INTEC/CONICET-UNL) Predio CONICET-Santa Fe Colectora RN 168 Km 472, Paraje El Pozo 3000 Santa Fe, Argentina Tel: +54-342-4511594 (ext 1011) Tel/Fax: +54-342-4511169