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

后端 未结 2 1028
深忆病人
深忆病人 2021-02-20 09:25

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

Every C++ compiler I have ever used had this kind of flag. How can I create dependencies a

2条回答
  •  说谎
    说谎 (楼主)
    2021-02-20 10:14

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

    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 \
    

    Outputs:

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

提交回复
热议问题