Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm reasonably sure that there isn't any way to do this.</p> <p>Both GCC and Clang do have internal interfaces which allow the language frontend to register <code>#pragma</code> handlers with the preprocessor - see GCC's <code>libcpp/directives.c</code> and Clang's <code>lib/Lex/Pragma.cpp</code> - but, as far as I can see, there is nothing which lets you modify which handlers are registered (beyond what is implied by the language variant you're compiling for) based on command line options.</p> <blockquote> <p>I know how to disable <em>all</em> unknown #pragma warnings. The answer was given, for example, here: <a href="https://stackoverflow.com/questions/132667/how-to-disable-pragma-warnings">SO: How to disable #pragma warnings?</a></p> </blockquote> <p>Note that the highest voted answer is better than the accepted one there. <code>-Wno-unknown-pragmas</code> can simply be added on the command line <em>after</em> anything (like <code>-Wall</code>) which turns the warning on.</p> <blockquote> <p>My source is parsed by two compilers. In one of those, there is a special <code>#pragma</code>, that is unknown to the other. Of course, I could probably put <code>#ifdef COMPILER_IDENTIFICATION_MACRO ... #endif</code> around every instance of the <code>#pragma</code> but that would be cumbersome.</p> </blockquote> <p>From a more philisophical viewpoint, I think this is really the right solution, cumbersome though it may be!</p> <p>It seems correct to me to hide any <code>#pragma</code> from a compiler which is not expected to understand it in the way that you intend, given that the whole point of <code>#pragma</code> is to provide a mechanism for invoking implementation-defined behaviour in the compiler.</p> <p>(If you do end up doing this, note that Clang defines <code>__clang__</code>, but <em>both</em> GCC and Clang define <code>__GNUC__</code>.)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload