本文介绍了是否存在MSVC的依赖关系生成标志,如gcc的-M的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSVC的依赖生成标志是否像gcc的 -M 标志。

Is there dependency generation flag for MSVC like gcc's -M flag.

曾使用过这种旗帜。我如何使用MSVC cl编译器自动创建依赖项

Every C++ compiler I have ever used had this kind of flag. How can I create dependenciesautomatically with MSVC cl compiler.


  1. 我只对最新的编译器版本感兴趣,例如MSVC9或更高版本但如果它与MSVC8一起工作,它也没问题。

  2. 如果有内置的外部工具来做到这一点(我的意思是,不是cl),那也可以。 li>
  1. I'm interested for only latest compiler versions i.e. MSVC9 or later but if it works with MSVC8 it is fine as well.
  2. If there is built-in external tool to do this (I mean, not cl), it would be fine as well


推荐答案

这个批处理脚本可能是您和我一直在寻找的,尽管我没有测试过

This batch script may be what you and I have been looking for, though I have not tested it.

将文件传递为%1并将路径包含为%2

Pass file as %1 and include path as %2

@ECHO %1: \
@FOR /F "tokens=1,2,3,*" %%A IN ('cl /nologo /c %1 /Zs /showIncludes /I%2') DO @IF NOT "%%D"=="" echo %%D \

输出:

filename.c: \
header.h \
someotherheader.h

这篇关于是否存在MSVC的依赖关系生成标志,如gcc的-M的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 10:41