Given:
#error /*
*/ foo
Microsoft C++ outputs an error message of /*
and GCC outputs foo
.
Which is correct?
GCC is correct.
Replacement of comments (including line-breaks) happens in translation phase 3, pre-processing in translation phase 4 (ISO/IEC 9899:1999, §5.1.1.2).
Hence, the preprocessing part of the compiler does not "see" the line-breaks anymore.
And, #error
is defined like this (§6.10.5):
A preprocessing directive of the form
# error pp-tokens_opt new-line
causes the implementation to produce a diagnostic message that includes the specified sequence of preprocessing tokens.
So, the foo
has to be part of the output.
GCC is correct because it should be replaced by a single space / * ... * /
in the standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With