preprocessor question - (nf)
dan at haddock.UUCP
dan at haddock.UUCP
Mon Mar 26 14:37:07 AEST 1984
#R:ccieng5:-30100:haddock:12400005:000:1125
haddock!dan Mar 24 18:15:00 1984
It can't be done. Not easily, anyway. The only reason it doesn't work is
that after the macro is expanded, there's no newline before the # to signal
the preprocessor that this is another control to process. You could modify
the preprocessor so that the sequence \<newline>, instead of being completely
dropped, turns into a <newline> in the macro definition (I know, I did it
once). But I don't recommend it. Instead, you might try writing the macro
with an embedded special character like '@' where newlines ought to appear,
running the source through cpp alone to expand the definitions, and then
running the result through 'tr' to convert those characters to newlines.
Then run the result through the preprocessor again (and the rest of the
compiler). Example:
#define foo(x) \
@#if x \
@some code \
@#endif
might be the source. The commands would be something like
cc -P foo.c; tr '@' '\012' <foo.i >x.c; cc x.c
I used -P because it will preserve line number information. Nonetheless,
the line numbers in diagnostics (and debuggers) should be regarded with
healthy skepticism the first few times you do this.
More information about the Comp.lang.c
mailing list