Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site uvacs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxb!houxm!whuxl!whuxlm!akgua!mcnc!ncsu!uvacs!rwl From: rwl@uvacs.UUCP (Ray Lubinsky) Newsgroups: net.lang.c Subject: Re: Re: Can #define `token-string' be empty? Message-ID: <1914@uvacs.UUCP> Date: Sun, 24-Feb-85 14:39:59 EST Article-I.D.: uvacs.1914 Posted: Sun Feb 24 14:39:59 1985 Date-Received: Wed, 27-Feb-85 21:02:18 EST References: <800003@acf4.UUCP> <151@cci-bdc.UUCP> Organization: U.Va. CS in Charlottesville, VA Lines: 37 > > 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... This is also the way I've understood #define, but I made a little program just to test it out. Fact is, X is not literally given a default value of 1. You can really only say that it has the value of "defined" as far as the pre-processor (/lib/cpp) is concerned. Consider the following C program which I fed to /lib/cpp : C source: Output from preprocessor: =================================== ======================================= #include ... (stuff from the include file here) #define X main() main() { { printf("This is X: %d\n",X); printf("This is X: %d\n",); } } Clearly, X was not considered to be 1 (or anything), and when I attempted to used the test #if X == 1 , the preprocessor complained of syntax error (since it translated the line into #if == 1 . Empty #define's should be used only in connection with #ifdef and #ifndef tests. Otherwise they have little usefulness. ------------------------------------------------------------------------------ Ray Lubinsky University of Virginia, Dept. of Computer Science uucp: decvax!mcnc!ncsu!uvacs!rwl -------------- The mind is buddha. The mind is not buddha. ----------------