2

Possible Duplicate:
Does there exist a static_warning?

I often use #warning scattered through my code to mark places where I need to come back to.

Like:

#warning The blahblah hasn't been implemented yet; use foo to do so.

I'd like to instead create a macro that optionally doesn't show the warnings specifically related to my notes, but shows actual warnings from the compiler and other libraries.

Something like:

#ifdef SUPPRESS_NOTES
    #define BUILD_NOTE
#else
    #define BUILD_NOTE #warning Note: msg
#endif

Unfortunately, #warning gets evaluated first. Is there any way I can do this? I use GCC (MinGW).

Community
  • 1
  • 1
Jamin Grey
  • 10,151
  • 6
  • 39
  • 52

1 Answers1

5

Using the TODO Makro from the GCC online doc, here is what you want:

#define DO_PRAGMA(x) _Pragma (#x)
#define TODO(x) DO_PRAGMA(message ("TODO - " #x))
#ifdef SUPRESS_NOTES
#  define BUILD_NOTE
#else
#  define BUILD_NOTE DO_PRAGMA(message ("The blahblah hasn't been implemented " \
                                        "yet; use foo to do so."))
#endif
ipc
  • 8,045
  • 29
  • 33