macros with parameters in MSC 5.0

der Mouse mouse at mcgill-vision.UUCP
Thu Mar 10 17:17:41 AEST 1988


In article <7309 at brl-smoke.ARPA>, gwyn at brl-smoke.ARPA (Doug Gwyn ) writes:
> In article <4099 at hoptoad.uucp> gnu at hoptoad.uucp (John Gilmore) writes:
>> jbaker at ee.UCLA.EDU (Joe Baker) wrote:
>>> #define ctl(c) ('c'&037)
>> This change caused us to have to fix more than 50 files in Berkeley
>> Unix.  [...A useful capability was removed, and replaced with a less
>> capable set of features.]
> First, this was NOT a change to the C language.  K&R already
> guaranteed that macro substitution would not occur inside string and
> character literals (section 12.1 of Appendix A).

So?  Macro arguments aren't macros.  I looked for a statement in K&R
that said that Reiser behavior was forbidden and failed to find
anything clear-cut.

The statement in 12.1 of Appendix A says that "Text inside a string or
a character constant is not subject to replacement.", but they don't
make it clear whether they mean replacement of macros with their
expansions or all replacement arising from the preprocessor.

> I daresay there are more instances of C compilers currently that do
> not do such substitution than those that do; [most that do are
> derived from AT&T's Reiser cpp].

Are you sure?  I would have guessed the other way.  I have no idea
where to look to obtain statistics to settle this; can anyone cite any
reference to such numbers?

> To see what is wrong with the Reiser method, try [...]:
> #define TEST(a,b) ((void)fprintf(stderr,"This is a test: 0x%x\n",(a)^(b)))

Yeah, and to see what's wrong with the ++ operator, try:

main() {  int i,j;
          i = 7;
          j = i++ + i++ + i++;
          printf("i = %d, j = %d\n",i,j);  }

The behavior exhibited by Reiser preprocessors is "wrong" only in that
it isn't how you believe it ought to work.  I see nothing wrong with
it.  The cited piece of K&R arguably supports you, but it arguably does
not support you.  And I claim that history supports me, because the
Reiser cpp is closer to the original cpp, the one used back when K&R
was written, than anything else around.  (Or at least so I believe, but
on trying I find I can't provide a source for this claim.  Can anyone
cite a source to support or demolish it?)

					der Mouse

			uucp: mouse at mcgill-vision.uucp
			arpa: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list