Search code examples
c++g++

How to WRITE compile time warning for user


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.


Solution

  • 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