0

我正在寻找一种一键式检查预处理或组装输出的方法。打开文件属性,更改相应设置,编译,转到 obj 目录并手动打开生成的文件,这很乏味。

有谁知道任何 Visual Studio 加载项、宏或任何可以自动执行此任务的东西?

4

1 回答 1

0

编辑:VS 11+ 的扩展可用@ https://github.com/Trass3r/DevUtils

我通过创建一个不错的宏自己解决了这个问题。它更复杂,但基本上是这样工作的:

Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine

Dim doc As EnvDTE.Document = DTE.ActiveDocument
Dim prj As VCProject = doc.ProjectItem.ContainingProject.Object

Dim file As VCFile = prj.Files.Item(doc.Name)
Dim fileconfigs As IVCCollection = file.FileConfigurations
Dim fileconfig As VCFileConfiguration = fileconfigs.Item("Release|x64")
Dim tool As VCCLCompilerTool = fileconfig.Tool

Dim asmFile = System.IO.Path.GetTempFileName + ".asm"
tool.WholeProgramOptimization = False
tool.AssemblerOutput = asmListingOption.asmListingAsmSrc
tool.AssemblerListingLocation = asmFile

fileconfig.Compile(True, True)
Dim window = DTE.ItemOperations.OpenFile(asmFile, Constants.vsViewKindCode)

与AsmHighlighter结合使用非常有用。

预处理文件可以类似地生成

tool.GeneratePreprocessedFile = preprocessOption.preprocessYes
' there's no separate option for this, so misuse /Fo
tool.ObjectFile = System.IO.Path.GetTempFileName + ".cpp"
于 2013-04-08T14:46:49.140 回答