#pragma Implementation-defined compiler instructions
#pragma Implementation-defined compiler instructions
#pragma provides implementation-defined instructions. Unknown pragmas are ignored; portable code cannot rely on #pragma once or #pragma message.
| Category | Preprocessor directives |
|---|---|
| Kind | Keyword / Statement |
| C standard | C89 / C90 |
📝 Syntax
#pragma implementation-defined-tokens
▶ Example
Edit the C code below and click Run; the server compiles and executes it:
Output:
Program completed
⚠️ Warning The behavior of #pragma is entirely implementation-defined. #pragma message(...) is a common extension, not ISO C89 functionality; a compiler may display the message or ignore the pragma.
ℹ️ Info The example does not depend on the pragma's effect: whether or not the compiler emits an additional diagnostic, a successfully compiled program prints Program completed.
🏷️ Related preprocessor directives
📚 Related Tutorials
❓ FAQ
QIs #pragma once part of ISO C89?
ANo. Many compilers support #pragma once as an extension, but it is not part of ISO C89. For a portable include guard, use #ifndef, #define, and #endif.
QIs #pragma message guaranteed to display a compiler message?
ANo. It is a common implementation extension, not a portable guarantee. Message formatting and display vary by compiler, and an unrecognized pragma may be ignored.
QWhat does a compiler do with an unrecognized #pragma?
AISO C requires an unrecognized pragma to be ignored, but implementations support different pragmas and effects. Essential behavior, such as layout or warning control, may therefore be lost. Portable code should provide a standard fallback and ensure the build detects any required extension that is unavailable.