Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!ncar!mephisto!mcnc!decvax!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.lang.c Subject: Re: Using (abusing) cpp.. Message-ID: <1506@tkou02.enet.dec.com> Date: 12 Apr 90 07:06:38 GMT References: <3358@jato.Jpl.Nasa.Gov> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 33 In article <3358@jato.Jpl.Nasa.Gov> hashem@mars.jpl.nasa.gov (Basil Hashem) writes: >I am not sure this is the most appropriate group, but let me try. It is. >#if (LANGUAGE == French) >#define GREETING Bonjour >#else >#define GREETING Good Morning >#endif >What I really need is a [preprocessing-time] strcmp(LANGUAGE, "French") >but I can't really do that considering this is not C. In fact, some programs (including a certain famous C-compiler itself, pcc) need a similar feature. "If you want PL/I, you know where to find it." The way pcc solves it is by #include of a header file with such things as: #define English 1 #define French 2 #define German 3 Since un"define"d preprocessor identifiers turn into zeroes in #if expressions, there is an advantage to not using 0 for a valid option. You can check: #if (LANGUAGE == 0) #error You set LANGUAGE to an unknown language (or you forgot to set it). #else ... -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com This_blank_intentionally_left_underlined________________________________________