passing 0 to const char[]

Andrew Spott andrew.spott at gmail.com
Tue Aug 14 14:39:59 PDT 2012


On Tuesday, 14 August 2012 at 21:33:34 UTC, Jonathan M Davis
wrote:
> On Tuesday, August 14, 2012 23:28:08 Andrew Spott wrote:
>> This appears to be the correct answer. I was mostly just
>> confused. something #defined is just replaced by the C
>> preprocessor (or so I thought), which means that in C, you 
>> would
>> be passing 0 to PetscInitialize... which seems weird.
>
> 0 _is_ the null value in C. What's weird is that they had a 
> non-standard macro
> for it (NULL is frequently used, but PETSC_NULL is not standard 
> at all).
>
> - Jonathan M Davis


There is some explanation in the header.  PETSC tries to be as
portable as possible, apparently there is some weird cases where
0 *isn't* the default value for NULL.


More information about the Digitalmars-d-learn mailing list