Can #define `token-string' be empty?

John Chambers jc at mit-athena.UUCP
Tue Feb 26 03:13:54 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
+---------------

Gee, I hope not.  This would undercut the following:
  #define then
  #define begin {
  #define end   }
  ...
   if (foo) then begin
     ...
     end
   else begin
     ...
   end
Now, maybe you like C's syntax.  I know I prefer it to the wordier
form in this example.  But there's really no reason other than taste
(about which there is an ancient Roman saying; I betcha you know it)
to object to this.  I have even used tricks like this to make the C
preprocessor do 90% of the work of "translating" programs to C.  If
#define didn't work correctly, I'd have to do something kludgy like
   #define then /**/
which I'd rather not do on general principal.  On a more general ground,
I'd much prefer the first #define above to behave literally ("Replace
'then' with nothing at all.") than to have the preprocessor make some
sort of special case out of it.  If I wanted "then" to be "1", I'd
rather say so explicitly.  Let's keep C reasonably simple.  It makes
my job easier.

			John Chambers (one of several)



More information about the Comp.lang.c mailing list