Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.c Subject: Re: Is this correct action for the c compiler/preprocessor ?? Message-ID: <198@opus.UUCP> Date: Mon, 4-Nov-85 03:27:49 EST Article-I.D.: opus.198 Posted: Mon Nov 4 03:27:49 1985 Date-Received: Tue, 5-Nov-85 07:23:25 EST References: <2667@brl-tgr.ARPA> <689@ucsfcgl.UUCP> Organization: NBI,Inc, Boulder CO Lines: 38 The question was whether the C preprocessor should substitute for an occurrence of a macro formal within a string within the body of the macro... > >It also fails to work correctly on the C compiler supplied with Un*x > >system V for the AT&T Un*x PC but it does work the opional LPI C > >compiler; But don't ask me why? >... > It does not "fail to work correctly" -- that's how it works. It > allows you to say something like > > # define Pval(var) printf("var = %d\n", var) > ... > pvar(Count); > pvar(Errors); > ... > Being able to insert literal text in strings is very useful. The fact that a feature is "useful" is not sufficient argument that it is correct. Ken Arnold (>) continues with a discussion about what happened in the standards committee--apparently they found it useful but didn't accept it. Leaving aside what happened there, and leaving aside the usefulness of the feature, the problem stems from the fact that the definition that most of us use these days (K&R) says one thing: Text inside a string or a character constant is not subject to replacement. ...which is pretty explicit, but the compiler that a lot of us use substitutes inside strings. I would like to have an authoritative definition and a correct compiler in accord with the definition. Lacking this, let's not throw too many stones; the compiler may not be wrong, but it's not clearly right. I'd like to know how the discrepancy came about--anyone care to fill me in (by email, preferably). -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Never attribute to malice what can be adequately explained by stupidity.