Visual Studio 2005 - external build, error parsing

U

Ulf Thorsen

I use Visual Studio 2005 for a C-project using an external compiler, and came
up with the idea that error parsing would be neat, i.e. enabling the
functionality
available for a "normal" build where you can double click a compile
error/warning message and be guided to the file/line in question.

Using sed to filter output from the compiler i managed to make the error
output look like the ones generated from the regular compiler, and hooray, it
seemed to work!

However, i found that in some cases double clicking an error message it will
crash the entire Visual Studio framework, and I simply can't figure out why.

Examples:

These two work, and are stable:

V:\ulth_view\gc900xp\cu\scu\c\scu_bas.c(338) : Error C0137 : expression must
be a modifiable lvalue
V:\ulth_view\gc900xp\cu\scu\c\scu_bas.c(333) : Warning C0177-D : variable
"iWontUseThis" was declared but never referenced

While this one is highly unstable:

V:\ulth_extended\gc800ext\CU\cu\scu\c\scu_bas.c(1001) : Error C0020 :
undeclared identifier "sculog"


I can't see the difference here, so if anyone can i'd be delighted to hear
any theories. If someone inside MS could explain in detail what happens when
you double click somewhere in the output window, it would also be valuable to
me.
I know I'm going a bit outside the scope of Visual Studio here, but when it
is working I find it highly useful, and so would probably others who use this
framework with external compilers.

PS: When writing this, i just realised there's another difference: The ones
that are working are in a single project solution, while the ones that aren't
are in a multi project solution. Perhaps this hasn't got anything to do with
error parsing to do at all, but rather the mechanism for finding a certain
file and focusing on it? I don't know.
 
U

Ulf Thorsen

Found a solution that works for me, thought I would share:

Apparently, Visual Studio has a problem with absolute paths, so I altered my
filter to use paths relative to the project directory, and now everything
seems to be working fine.

I use sed to filter the output from my build script:

--------- START Build.bat:
(…..)
CALL mm.bat 2<&1 | sed -u -f ..\..\errfix.sed
(…..)
--------- END

, where mm.bat is the build file i use outside Visual Studio (no error
parsing), and errfix.sed contains regular expressions adapted to my compilers
output:

------- START errfix.sed
#MPC561 - TYPE:\1 ID:\2 FILE:\3 LINE:\4 POS:\5 REST:\6
s/^(\([EWI]\)) \([A-Z][0-9]*-*[A-Z]*\); "\(.*\)", line \([0-9]*\) pos
\([0-9]*\); \(.*\)/\3(\4) : (\1) \2 : \6/
s/(E)/Error/g
s/(W)/Warning/g
s/(I)/Informational/g
s/..\\..\\..\\cu\\//
s/..\\..\\../../
------- END

Example

(compiler, raw output):

"..\..\..\cu\mcu\c\bastask.c", line 155 pos 9; (E) undeclared identifier
"IncrementBeefnGenerated"

(after filtering)

mcu\c\bastask.c(155) : Error C0020 : undeclared identifier
"IncrementBeefnGenerated"

Summary:

In order to make Visual Studio parse the error message correctly, the errors
and warnings need to look something like this:

<FILE>:<ERROR ID>:<DESCRIPTION>

, where

<FILE>=<FILENAME(relative path)>(<LINE NUMBER>)
<ERROR ID>=<â€Errorâ€|â€Warningâ€|â€Informationalâ€> <Free text> # not sure
if the string is parsed at all
<DESCRIPTION=<Free text> # should probably not contain ’:’
 
B

Ben Voigt [C++ MVP]

Ulf Thorsen said:
Found a solution that works for me, thought I would share:

Apparently, Visual Studio has a problem with absolute paths, so I altered
my
filter to use paths relative to the project directory, and now everything
seems to be working fine.

I use sed to filter the output from my build script:

--------- START Build.bat:
(...)
CALL mm.bat 2<&1 | sed -u -f ..\..\errfix.sed
(...)
--------- END

, where mm.bat is the build file i use outside Visual Studio (no error
parsing), and errfix.sed contains regular expressions adapted to my
compilers
output:

------- START errfix.sed
#MPC561 - TYPE:\1 ID:\2 FILE:\3 LINE:\4 POS:\5 REST:\6
s/^(\([EWI]\)) \([A-Z][0-9]*-*[A-Z]*\); "\(.*\)", line \([0-9]*\) pos
\([0-9]*\); \(.*\)/\3(\4) : (\1) \2 : \6/
s/(E)/Error/g
s/(W)/Warning/g
s/(I)/Informational/g
s/..\\..\\..\\cu\\//
s/..\\..\\../../
------- END

Example

(compiler, raw output):

"..\..\..\cu\mcu\c\bastask.c", line 155 pos 9; (E) undeclared identifier
"IncrementBeefnGenerated"

(after filtering)

mcu\c\bastask.c(155) : Error C0020 : undeclared identifier
"IncrementBeefnGenerated"

Summary:

In order to make Visual Studio parse the error message correctly, the
errors
and warnings need to look something like this:

<FILE>:<ERROR ID>:<DESCRIPTION>

, where

<FILE>=<FILENAME(relative path)>(<LINE NUMBER>)
<ERROR ID>=<"Error"|"Warning"|"Informational"> <Free text> # not sure
if the string is parsed at all
<DESCRIPTION=<Free text> # should probably not contain ':'

Nice.

I remember going the other way once to let vim's error list work with the MS
compilers (for development via ssh).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top