Re: Portabilität: NULL
- From
- Mathias Waack <mathias@...>
- Date
On Friday 16 August 2002 04:15, Alexander Holler wrote: > Die NULL in C(++) ist nicht unbedingt gleich 0. Es ist zwar ziehmlich > unmöglich alle Programme dahingehend anzupassen (wer macht nicht lieber > if(!var) anstatt if (var != NULL) aber es gibt eine Hardware (kann mich > nicht mehr entsinnen welche) bei der NULL != 0 ist. Also in C++ funktioniert das mit Sicherheit immer aufgrund der strengeren Typregeln. Die meisten Styleguides empfehlen die Benutzung von 0 anstelle von NULL. NULL ist ein C-Relikt welches in C++ nicht benutzt werden sollte. In C siehts dann so aus: 6.3.2.3 Pointers 3 An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.55) If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function. 4 Conversion of a null pointer to another pointer type yields a null pointer of that type. Any two null pointers shall compare equal. 55) The macro NULL is defined in <stddef.h> (and other headers) as a null pointer constant; see 7.17. Also wenn ich das richtig verstehe ist entweder Deine Erinnerung oder Deine damalige Software broken;) Mathias
Thread
In reply to: Portabilität: NULL Alexander Holler <holler@...>
Follow-ups:
- Re: Portabilität: NULL Alexander Holler <holler@...>