#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.

CategoryPreprocessor directives
KindKeyword / Statement
C standardC89 / 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 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.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏