I would like to write a Pragma warning in GNU G++ for every user that compile my codes.
How can i do this? I am using GNU G++ compiler.
Compile-time warnings can greatly improve the maintainability of your code and reduce the chance that bugs will creep into it. Compile-time warnings differ from compile-time errors; with warnings, your program will still compile and run.
A compiler warning signals a potentially serious problem in your code. The problems listed above are almost always fatal; others may or may not be, but you want compilation to fail even if it turns out to be a false alarm. Investigate each warning, find the root cause, and fix it.
However, in general, code with lots of warnings is more likely to be sloppy, and therefore more likely to be inefficient and wasteful (and probably buggy to boot). The more warnings you have, the more stuff that needs to be printed, and the longer the compilation runs.
MSVC and newer GCCs support:
#pragma message ( "your warning text here" )
In GCC the other syntax is also commonly used:
#warning "you warning text here"
See also question: Portability of #warning preprocessor directive and GCC documentation
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