T
Tim Rentsch
Keith Thompson said:James Kuyper said:On 05/14/2012 05:37 PM, Robert Wessel wrote:
...
You've got the syntax wrong. _Pragma("string literal") is equivalent to
#pragma string literal
C99 was the first version of the standard to introduce standard-defined
pragmas, and it also established naming conventions which should be
adhered to by any additional pragmas that are proposed. Every standard
pragma has a name which is all capitals, and contains at least two
words, the first of which is "STDC". Those which turn a feature either
on or off do so by simply appending "ON" or "OFF" to the pragma's name.
Therefore, that should be _Pragma("STDC TRIGRAPHS ON")
The standard says:
A unary operator expression of the form:
_Pragma ( string-literal )
is processed as follows:
[snip]
Which implies (I think) that _Pragma(...) may appear only in a context
where an expression is permitted.
In particular, it implies that you can't have a _Pragma as the first line of
a source file.
But the example, showing a way of rewriting a #pragma directive as an
equivalent _Pragma(), doesn't support that interpretation, nor does the
C99 Rationale. The phrase "unary operator expression" is also a bit
odd; the grammatical construct is a "unary-expression".
I agree the phrasing is a little odd. Despite that, I think
the meaning is clear enough, especially when read in conjunction
with other parts of the Standard describing the preprocessor
and what happens with _Pragma, and when.
I'll post to comp.std.c and see if I can get some clarification.
I'd support a recommendation to add a clarifying footnote or two
to help fix this; IMO nothing more than that is warranted.