Search code examples
c++gccpragma

gcc equivalent of #pragma comment


I'm trying to write a macro that adds a comment to an executable with the gcc compiler. This is not for linking purposes, I simply want to add text comments. Is there a #pragma comment equivalent in gcc for this purpose?


Solution

  • I'm not sure what it means to "add a comment to an executable". Who or what is going to consume, display, or even notice such comments? Nevertheless, if you just want to ensure some string is embedded somewhere in your program, then simply declare it as an ordinary (C) string at file scope.

    static const char my_comment[] = "This comment should appear in the compiled executable";