pragmas vs preprocessors
Henry Spencer
henry at zoo.toronto.edu
Sat Jan 12 05:07:05 AEST 1991
In article <1991Jan10.153117.29024 at fs7.ece.cmu.edu> nydick at psc.edu (Dan Nydick) writes:
>I have an application where I'd like to have a macro expand into
>a #pragma...
Can't be done. The wording of the standard could use a bit of cleanup,
but 3.8.3 refers you to 3.8.3.4 for rescanning of both kinds of macros,
and 3.8.3.4 is quite explicit: "The resulting completely macro-replaced
preprocessing token sequence is not processed as a preprocessing directive
even if it resembles one."
>... Or even, how
>could one write a conditional expression so the pragma
>only appears if certain symbols are defined (plain ifdefs
>around the pragma are not good enough since some non-ansi
>compilers will complain about #pragma even inside a "false"
>condition)?
Try indenting the #pragma; most pre-ANSI compilers will not "see" a
directive unless the `#' is the first character on the line:
#ifdef foobar
#pragma pre-ANSI compilers probably will not see this
#endif
>Is a #pragma supposed to be significant to the
>compiler or to the pre-processor?
Yes. :-) The standard does not require the separation between compiler
and preprocessor; indeed, there are many implementations which integrate
the preprocessor into the compiler's scanner.
--
If the Space Shuttle was the answer, | Henry Spencer at U of Toronto Zoology
what was the question? | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.std.c
mailing list