[s1mp3-dev] Linux patch to s1mp3
M. Warner Losh
imp at bsdimp.com
Tue Jun 20 00:41:28 CDT 2006
In message: <7.0.1.0.2.20060619233014.03b63408 at gmail.com>
Bluechip <csbluechip at gmail.com> writes:
: >Actually, NULL should be defined as a plain '0'. Comparison of
: >pointers against 0 is a special case in 'C' as is casting 0 to a
: >pointer. Both should be the same. In this context, the definition of
: >NULL doesn't matter. It only matters when calling functions
: >w/old-school K&R prototypes or through "...".
: >
: >I agree we should compare against NULL if the functionr returns a
: >pointer.
:
: I disagree. I personally never use NULL because
: every damn system defines it differently and
: compilers belch all over the shop. This is an
: except from one of my standard include files:
:
: #define cpNULL ((char*)0)
: #define vpNULL ((void*)0)
: #define bpNULL ((UI8 *)0)
: #define wpNULL ((UI16*)0)
: #define dpNULL ((UI32*)0)
: #define sNULL ((char)0)
That's ugly beyond belief. Why use a non-standard thing when a
standard one will do? You need a special #define for each type, which
is an insane explosion of defines, all of which are non-standard.
: // The empty string: 'empty'
: // (Didn't really seem worthy of a global definition)
: static const char scach1_NULL[1] = {'\0'};
: #define empty ((char*)scach1_NULL)
Ugg. That's even worse.
const char *empty="";
is a lot clearer, and you'll wind up with only one copy of the empty
string rather than one per file.
: You can also choose whether to debate #define
: over typedef ...which will ALSO cause compilers to behave differently.
Please, no #defined types. They are always wrong. They haven't been
right since typedef was introduced into the language around v7.
Warner
More information about the s1mp3-dev
mailing list