close-order manual reading - (nf)
jejones at ea.UUCP
jejones at ea.UUCP
Tue Jun 12 05:24:00 AEST 1984
#N:ea:5700011:000:1174
ea!jejones Jun 11 14:24:00 1984
Just another note on the C preprocessor and on exegesis from K&R: I had a
program for which I thought I'd write a common macro to report errors, and wrote
#define error(s) fprintf(stderr, "prog: line %d--%s\n", (s))
to do the job, I thought. Feeling mildly smug, I compiled the program that
contained this #define, and came back with errors. Checking the resuls from
the preprocessor showed that the preprocessor was replacing the s in %s
with the actual parameter when I used the error macro.
Gee, I thought; doesn't the sentence under section 12.1, "Token Replacement,"
on page 207 of K&R,
Text inside a string or a character constant is not subject
to replacement.
imply that that shouldn't happen? I thought it did, but experimentation on
a machine running 4.2 BSD (I was using a microcomputer C compiler the first
time around) gave the same results.
The fix to this particular problem is, of course, straightforward, and I
have done it and gone on my way, but I present it here as an example.
To paraphrase Raymond Smullyan, doesn't this make you think that there's
something just a little bit wrong with English specification of semantics?
James Jones
More information about the Comp.lang.c
mailing list