This little macro prints out user warnings to the output window in a format the “Error List” within Visual Studio will understand and parse. Taken from Stack Overflow and modified a little.
#define STRINGISE_IMPL(x) #x #define STRINGISE(x) STRINGISE_IMPL(x) // Use: #pragma message WARN("My message") #if _MSC_VER # define FILE_LINE_LINK __FILE__ "(" STRINGISE(__LINE__) ") : " # define WARN(exp) (FILE_LINE_LINK "warning: " exp) #else//__GNUC__ - may need other defines for different compilers # define WARN(exp) ("WARNING: " exp) #endif
It will produce output like this:
1>.srcbug.cpp(82) : warning: check me
When this line is present in the source file.
#pragma message WARN("check me")