Can #define `token-string' be empty?

Rob Warnock rpw3 at redwood.UUCP
Fri Feb 22 16:01:40 AEST 1985


+---------------
| > Is
| > 	#define	X
| > valid, i.e., can the `token-string' mentioned on page 207 of K&R be empty?
| Yes.  the default value of X is 1.  |	larry...
| uucp:  ..mit-eddie!cybvax0!cci-bdc!larry | arpa:  henrik at mit-mc.ARPA
+---------------

Well, almost, Larry. There is no "default" for a "#define"; the empty
token-string is perfectly legal. See K & R page 87 for an example of an
empty token-string (the "then" macro).

You are probably thinking of the case of a symbol defined on the "cc"
command line with no value, as in "cc -DFOO bar.c" which defines "FOO"
to be 1. But if it is given a value the value is used, even if empty,
as in "cc -DFOO= bar.c" which defines "FOO" to be empty, not 1.


Rob Warnock
Systems Architecture Consultant

UUCP:	{ihnp4,ucbvax!dual}!fortune!redwood!rpw3
DDD:	(415)572-2607
USPS:	510 Trinidad Lane, Foster City, CA  94404



More information about the Comp.lang.c mailing list