Visual Studio C 编译器是否有与 GCC 的 -M 等效的编译器?
我想自动生成 Makefile 依赖项列表,但我使用的是 Visual Studio 2005。如果我使用 GCC,我可以传递 -M (或许多变体之一)来创建此依赖项列表。
查看 cl.exe 的命令行选项,我没有看到任何明显的东西。我可以通过后处理来调整输出,但越接近越好。
I would like to automatically generate a Makefile dependency list, but I am using Visual Studio 2005. If I were using GCC, I could pass -M (or one of the many variants) to create this dependency list.
Looking through the command line options to cl.exe
, I don't see anything obvious. I can handle tweaking the output with post-processing, but the closer the better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
至少在Visual Studio 2005的cl.exe中,有选项
/showIncludes
。In the cl.exe of Visual Studio 2005 at least, there is the option
/showIncludes
.我必须解决这个问题。我们想添加一个脚本来替换 -M 选项。我是这样做的:
我就是这么做的,而且很有效。祝你好运!
I had to deal with that exact problem. We wanted to add a script that replaces the -M option. Here's how I did it:
It's how I've done it, and it worked. Good luck!
编译器将依赖项存储在中间 .idb 文件中。您也许可以从那里解析它。
请参阅 https://msdn.microsoft.com/en-us/library/kfz8ad09 .aspx
您似乎可以在其中找到所有以“/mr/inversedeps/”或“/ipm/header/”为前缀的包含文件。
我认为您还应该在其他中间文件中找到依赖项,例如“CL.read.1.tlog”。
The compiler stores dependencies in the intermediate .idb file. You might be able to parse it from there.
See https://msdn.microsoft.com/en-us/library/kfz8ad09.aspx
You can find all included files prefixed with "/mr/inversedeps/" or "/ipm/header/" in there, it seems.
I think you should also find dependencies in other intermediate files, e.g. "CL.read.1.tlog".
不直接使用 cl.exe,但使用此包装器您可以实现您正在寻找的内容:
http://msdn.microsoft.com/en-us/library/y209k0z6.aspx
Not directly with cl.exe, but with this wrapper you can achieve what you're looking for:
http://msdn.microsoft.com/en-us/library/y209k0z6.aspx
我们在使用 Fortran 时遇到了完全相同的问题,最终不得不编写自己的迷你编译器来扫描源代码并遍历所有
#includes
。We had the exact same issue with Fortran, and ended up having to write our own mini-compiler to scan the source code and traverse all the
#includes
.