Many lines from a macro?

Norman Diamond diamond at jit345.swstokyo.dec.com
Thu Jan 24 13:51:10 AEST 1991


In article <1991Jan22.201702.1383 at quagga.ru.ac.za> cspw at quagga.ru.ac.za (Peter Wentworth) writes:

>Can a C macro replacement ever result in more than one output line from
>the preprocessing stage?

In obscure cases, it is possible, depending on the implementation.
But not in any reliable or useful manner.
(The imaginable case is where the macro call has arguments on more than
one line.)

>I am using the SUN assembler which first uses the C preprocessor.

Cute.  But as you've observed, not especially useful.

>The C macro
>#define FOO       jmp label;\
>                  nop;\
>              label:
>expands to this output:       jmp label;  nop;  label:

There is no real choice in this matter.  The backslash-newline pairs are
deleted before the preprocessor even sees the macro definition.

>But the assembler insists that the label starts on a new line,

>I don't think this can ever cause problems in C,

Of course not.

>but I suspect
>there other languages that would benefit from using a general
>standardized C preprocessor as a front end.

There is a relatively portable preprocessor called M4.  It is cute that
no one wants to use M4 to preprocess C programs, but some people want to
use the C preprocessor to preprocess programs for other languages.

>Was there ever any
>notion among the ANSI committee that things like preprocessing
>features could be included on grounds of 'general usefulness',
>rather than 'useful only to C'?

When the ANSI C committee standardized C, even "useful to C" was not
always a criterion.  Often only "prior art" or "base document" were
criteria.  In cases were "useful" was the primary criterion, some of
the results are unpopular.

Other ANSI committees standardize other languages (and other industries
besides the computer business).  If you want to standardize a macro
processor, get a bunch of computer companies together and apply to
form another ANSI committee.
--
Norman Diamond       diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.



More information about the Comp.lang.c mailing list