Visual Studio makefile 项目在编辑器中未显示错误
我使用 ARM 编译器 (RVDS) 并使用 Visual C++ 2005 Express 作为我的 IDE,因为我不喜欢 ARM 选择的旧版本 Eclipse。我创建了一个可以正确构建的 makefile 项目。不幸的是,当出现编译错误时,错误会显示在“错误”窗格中,但双击错误不会在编辑器中打开文件。
在“错误”窗格中显示了正确的文件,但行号为空。有没有办法让 Visual C++ 更好地解析错误消息以提取正确的行号并将错误链接到编辑器?
更新: 当我在与 makefile 或构建脚本相同的目录中创建解决方案/项目时,Visual C++ 正确解析了编译器输出。仅当解决方案/项目是在与 makefile 不同的目录中创建时,我才遇到此问题。
I'm using an ARM compiler (RVDS) and using Visual C++ 2005 Express as my IDE because I'm not a fan of the old version of Eclipse that ARM chose. I created a makefile project which builds correctly. Unfortunately when there is a compile error the error shows up in the "Error" pane, but double clicking the error does not open the file in the editor.
In the "Error" pane the correct file is shown, but the line number is blank. Is there a way to get Visual C++ to better parse the error messages to extract the correct line numbers and link the errors to the editor?
UPDATED:
Visual C++ parsed the compiler output correctly when I created the solution/project in the same directory as the makefile or build scripts. I only had this problem when the solution/project was created in a different directory than the makefile.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
过去,我使用过一个脚本将第 3 方编译器的错误消息过滤为 Visual Studio 期望的格式。我已经丢失了脚本(由于一段时间不需要它们,换工作等)。
这是 Microsoft 新闻组帖子的镜像(我在 Google 网上论坛中找不到该帖子),它描述了类似的过程以及 sed 脚本:
相关信息是 VS 构建配置启动该工具并通过 sed 脚本传输输出:
以及 sed 脚本:
我想该脚本需要根据您的特定工具进行定制 - 该脚本乍一看非常令人生畏(无论如何对我来说),但我敢打赌让它将输出按摩到 VS 期望的程度不会太困难。
In the past I've used a script that filtered my 3rd-party compiler's error message into the format Visual Studio expects. I've since lost the scripts (due to not needing them in a while, changin job, etc.).
Here's a mirror of a Microsoft newsgroup posting (I can't find the post in Google Groups) that describes a similar process along with a sed script:
The relevant information is that the VS build configuration launches the tool and pipes the output through a sed script:
and the sed script:
I imagine the script would need to be tailored to your particular tool - the script looks pretty intimidating at first glance (to me anyway), but I 'd bet it wouldn't be too difficult to get it massage the output to what VS expects.
万一其他人在这个问题上绊倒。这就是我最终得到的结果:
这适用于 file.c:line#: error desc 的 gcc 错误格式(例如 main.c:12: HelloWorld 未定义)
2<&1 位确保我们也捕获 stderr,第一个 sed 替代品将 cygwin 驱动器映射回 Windows(我的情况),第二个替代品将 :dd: 错误格式替换为 (dd): 对于以 .c 或 .h 结尾的文件。
最后,通过 exit ${PIPESTATUS[0]} 位维护 make 的退出状态,这样 Visual Studio 不会仅仅因为 sed 成功就认为构建成功。
In case someone else trips on this issue. Here's what I ended up with:
This works for gcc error formats of file.c:line#: error desc (e.g. main.c:12: HelloWorld is undefined)
The 2<&1 bit makes sure we capture stderr as well, the first sed substitute replaces cygwin drive mapping back to windows (my case), and the second replaces the :dd: error format with (dd): for files ending with .c or .h.
finally, the exit status of make is maintained through exit ${PIPESTATUS[0]} bit so that visual studio doesn't think build succeeded just because sed succeed.