How to force absolute paths for build errors output in Visual Studio
Asked Answered
I

1

2

When building in most Visual Studio (2008, but I doubt it matters) projects, if there is error, it lists the absolute path of the file with the error. Like this (ignore the specific errors--I added them intentionally):

1>dope_external.cpp
1>c:\users\me\dope_external.cpp(4) : error C2144: syntax error : 'void' should be preceded by ';'
1>c:\users\me\dope_external.cpp(4) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Generating Code...

However, the solutions/projects I'm currently working with list relative path names:

1>FileBasedEffect.cpp
1>..\..\..\..\..\..\..\..\tools\blah\code\src\important_file.cpp(10) : error C2653: 'FusionEffectKeys' : is not a class or namespace name
1>..\..\..\..\..\..\..\..\tools\blah\code\src\important_file.cpp(10) : error C2143: syntax error : missing ';' before 'const'
1>..\..\..\..\..\..\..\..\tools\blah\code\src\important_file.cpp(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

This happens in Visual Studio and also if I build from the command-line or in another environment using vcbuild. I'd like to use a different environment to build, at least as an experiment. But the relative paths are horking me a little.

I don't spot any differences in the project properties that are obvious like "UseRelativePathsInBuildErrors", but I don't know the build system that well. Any ideas? Thanks.

Ingrain answered 8/8, 2012 at 22:23 Comment(4)
I wonder if it's just the length of the path. Can you try moving the dope_external project you created into a directory somewhere deep in the filesystem and see if the paths start being truncated?Croton
I don't know if this will fix the issue because I can't recreate your errors, but in the Tools-> Options -> Build and Run: You'll see a setting for MSBuild poject build output verbosity. Try to set it to detailed or even diagnostic. Let me know please.Russophobe
@jwismar: good idea but even with a very deep directory level I still see this.Ingrain
@RobertoWilko: doing that didn't "fix" things, but I looked at the command-line and in the case where it shows relative paths, the relative path is passed into cl on the command-line and absolute paths are used in the case where it shows an absolute path.Ingrain
I
5

I found a solution.

In project properties->configuration properties->c/c++->Advanced, there is a "Use Full Paths" option which appears to make vcbuild pass the /FC flag to cl.exe. This produces full paths in output.

so that solves my problem...but that option isn't set in the case where I already see full paths, so there's something else at play here.

Ingrain answered 9/8, 2012 at 16:23 Comment(1)
The /ZI flag (used to get "Edit and Continue" support and almost certainly on in debugging builds) implies /FC (see the documentation). That's probably why you are seeing full paths even without the /FC option being explicitly set.Smoky

© 2022 - 2024 — McMap. All rights reserved.