0

I am using MSVS2013.

I have setup a custom makefile C++ project that essentially calls a batch file that I wrote to invoke my compiler.

The output of my compiler creates warnings in the format:

>>> Warning <code> "c:\some\file\path\somefile.h" Line <num>(x,y): warning comment

or

>>> Warning <code> "somefile.c" Line <num>(x,y): warning comment

Note: The second one does not have the whole path, just the filename (not sure why), but the file is in the project source files list - so it should know about it.

When I double click the warning line visual studio does not open the file on that line. I am assuming that this is becuause it does not understand the syntax of the warning line to parse it.

So my question is how can I get MSVS2013 to parse the warning correctly?

code_fodder
  • 15,263
  • 17
  • 90
  • 167
  • 1
    See e.g. https://stackoverflow.com/questions/42955711/showing-errors-from-a-build-time-tool-with-source-file-line, you need to match the format VS expects – stijn Aug 31 '17 at 11:54
  • @stijn ...ah....bugger ... I guess this means I got to write some code somewhere : ( – code_fodder Aug 31 '17 at 12:02
  • Well, unless somebody comes up with another way. E.g. the Exec task has a CustomWarningRegularExpression attribute so that might be useful but I don't think the Makefile projects support it out of the box. But maybe it can be overridden. – stijn Aug 31 '17 at 12:25
  • @stijn yeah, I am kind of surprised there is not something already. VS is a pretty good IDE (if not a bit heavy-weight). Other decent IDE's have these kinds of features already - but they are specifically targeted to custom build systems. – code_fodder Aug 31 '17 at 12:30
  • I tried CustomWarningRegularExpression but it's not super useful: it can be used to treat anything matching the regex as a warning, so it will show up in the Eror List, but you cannot click it to go to the source file/line (because the format doesn't match what VS wants). So I don't think there's another way than to parse output and convert it to the wanted format. Maybe you can get pointers on how to do that from clang/llvm or so, since they have VS integration – stijn Aug 31 '17 at 12:52
  • @stijn hmm, I'll take a quick look there - but I am thinking its probably easier to "wrap" my compiler in a parser. There is probably some crazy awk or sed one-liner I can use to shuffle the parameters around :o – code_fodder Aug 31 '17 at 13:00
  • Yeah awk or so should do it, be sure to post it as an answer if you find it. Or make your compiler output style configurable :]. Also look at https://stackoverflow.com/questions/33572091/visual-studio-doesnt-recognize-gcc-linker-errors-in-makefile-project etc – stijn Aug 31 '17 at 13:14
  • 1
    @stijn just in case you where interested - awk script is in the answer to the question in the link in my answer below... err...make sense? : ) – code_fodder Sep 04 '17 at 09:33
  • yeah makes sense :] – stijn Sep 04 '17 at 09:55

1 Answers1

0

In the end it was easiest to write a little bit of awk script to solve this (which can be applied to any compiler). My knowledge of awk is not so good so I did spend quite a lot of time trying to figure it out - ended up post another question to help complete it, so see the link below (the answer) for a decent implementation that is easy to modify for any compiler output:

gawk script answer here

code_fodder
  • 15,263
  • 17
  • 90
  • 167