7

What's Clang's equivalent to #pragma message as used in GCC and MSVC?

Matt Joiner
  • 112,946
  • 110
  • 377
  • 526

2 Answers2

6

I've brought this up on the Clang mailing list, and it's in discussion now. It's subsequently been implemented as a warning, and hopefully soon it will be behave as it does in other compilers.

Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
  • 2
    It is unfortunately implemented as a warning I'd say, but then I already replied on the mailing list. – Matthieu M. Sep 28 '10 at 18:30
  • @Mattieu M. By all means please provide an answer of your own, you are somewhat a first hand source on this :) – Matt Joiner Sep 29 '10 at 03:26
  • it is present at least since clang 3.0. And even if the output says "1 warning generated", it doesn't fail build with `-Werror`: https://gcc.godbolt.org/z/bcPGYr – ead Nov 21 '20 at 23:19
0

#pragma message has been implemented recently - too recently for the current release (2.7), but it should be included in the forthcoming 2.8.

Matthew Slattery
  • 45,290
  • 8
  • 103
  • 119
  • I am using clang from SVN and it's not present. Do you have more information? `matt@stanley:~/cpfs$ clang --version clang version 2.9 (trunk 114802)` – Matt Joiner Sep 26 '10 at 12:39
  • Ah... looking at the code (end of `lib/Lex/Pragma.cpp`), it seems that it's being treated as one of the "Microsoft extension" features which are enabled with the `-fms-extensions` option. (I don't have a version more recent than 2.7 to hand to try myself at the moment.) – Matthew Slattery Sep 26 '10 at 13:08