Newsgroups: comp.std.c
Path: utzoo!henry
From: henry@zoo.toronto.edu (Henry Spencer)
Subject: Re: pragmas vs preprocessors
Message-ID: <1991Jan11.180705.9089@zoo.toronto.edu>
Organization: U of Toronto Zoology
References: <1991Jan10.153117.29024@fs7.ece.cmu.edu>
Date: Fri, 11 Jan 1991 18:07:05 GMT

In article <1991Jan10.153117.29024@fs7.ece.cmu.edu> nydick@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@zoo.toronto.edu   utzoo!henry
