Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The type of NULL

18 views
Skip to first unread message

kzelec...@e3tech.local

unread,
Apr 18, 2013, 5:26:49 AM4/18/13
to
The expression (NULL == 1) should cause a compile-time error because NULL is
a pointer type in C, isn’t it? But LCC accepts the syntax without a
complaint.
Chris

Keith Thompson

unread,
Apr 18, 2013, 11:42:29 AM4/18/13
to
NULL is a macro that expands to an implementation-defined null pointer
constant. A literal 0 is a null pointer constant; so is `((void*)0)`.
If an implementation has `#define NULL 0`, then `(NULL == 1)` will
compile without error.

A warning would be nice (NULL *should't* be used in that context), but
it's not required.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
0 new messages