3 ms·
I remember one early version of a C++ compiler which had NULL #defined as (( void* )0), which caused all manner of fun trying to compile some legacy C code. Th
by qwph 18y ago
I remember one early version of a C++ compiler which had NULL #defined as (( void* )0), which caused all manner of fun trying to compile some legacy C code.
This was in 1999, I think.
- tptacek 18y agoYou mean like this? #define NULL __DARWIN_NULL ... #define __DARWIN_NULL ((void *)0)
- qwph 18y agoSomething like that. It makes the following invalid in C++ but valid in C: int *ptr = NULL;
- bdash 18y agoExcept for the fact that the real definition is actually more like: #ifdef __cplusplus #define __DARWIN_NULL __null #else /* ! __cplusplus */ #define __DARWIN_NULL ((void *)0) #endif /* __cplusplus */ So the code you mentioned works just fine in C++.
- qwph 18y agoExcept that the actual compiler I was using was for the PlayStation 2, so I very much doubt it had that precise code you just outlined, and it really did have NULL defined as ((void* )0), and it really did break. I saw it happen.