Creating Visual Studio Error List Messages

2k views Asked by At

Is there any way to create a custom message in the Visual Studio error list? I'm looking at VS 2010 and 2012.

For generating errors, it's a simple #error text. For generating warnings it's #pragma warning ("text"). For printing a message to the Output window, it's #pragma message("text")

There's little or no documentation on how to create a information message in the Error List. Anyone know if it is possible? I'd prefer if no VS addons would be used, but if there is a way with those, that would be fine too.

2

There are 2 answers

1
Parallel Universe On

And this macro is a possible implementation of what Rost linked to :

#define COMBINE_NAMES_HELPER_6(a,b,c,d,e,f)                   a##b##c##d##e##f
#define COMBINE_NAMES_6(a,b,c,d,e,f)                          COMBINE_NAMES_HELPER_6(a,b,c,d,e,f)

#define FILE_LINE_FUNC_STR(msg)   ( COMBINE_NAMES_6(__FILE__, "(",STRING( __LINE__), "): ", __FUNCTION__, " "msg) )
#define COMPILER_MSG(msg)         message FILE_LINE_FUNC_STR(msg)
0
Rost On

Possibly this may help: Formatting the Output of a Custom Build Step or Build Event or https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-diagnostic-format-for-tasks?view=vs-2022

Formatting the Output of a Custom Build Step or Build Event

If the output of a custom build step or build event is formatted correctly, users get the following benefits:

  • Warnings and errors are counted in the Output window.

  • Output appears in the Task List window.

  • Clicking on the output in the Output window displays the appropriate topic.

  • F1 operations are enabled in the Task List window or Output window.

The format of the output should be:

{filename (line# [, column#]) | toolname} :

[any text] {error | warning} code####: localizable string