VCCLCompilerTool 介面
VCCLCompilerTool 物件會公開 C++ 編譯器選項的功能。 如需編譯器選項的詳細資訊,請參閱編譯器選項。
命名空間: Microsoft.VisualStudio.VCProjectEngine
組件: Microsoft.VisualStudio.VCProjectEngine (在 Microsoft.VisualStudio.VCProjectEngine.dll 中)
語法
'宣告
<GuidAttribute("3D6193F2-8B5D-4B0A-967F-7D163D918848")> _
Public Interface VCCLCompilerTool
[GuidAttribute("3D6193F2-8B5D-4B0A-967F-7D163D918848")]
public interface VCCLCompilerTool
[GuidAttribute(L"3D6193F2-8B5D-4B0A-967F-7D163D918848")]
public interface class VCCLCompilerTool
[<GuidAttribute("3D6193F2-8B5D-4B0A-967F-7D163D918848")>]
type VCCLCompilerTool = interface end
public interface VCCLCompilerTool
VCCLCompilerTool 類型會公開下列成員。
屬性
回頁首
方法
名稱 | 描述 | |
---|---|---|
get_PropertyOption | 基礎架構。 僅供 Microsoft 內部使用。 |
回頁首
備註
下列新的編譯器選項在 Visual Studio 2005加入:
下列編譯器選項在 Visual Studio 2005中移除:
/Op
/G6、/G7 和 /GB
範例
下列範例示範如何使用 EnablePREfast 和 AdditionalOptions 屬性設定 /analyze:WX- 參數。(需要兩個屬性即可)。指定 /analyze:WX- 表示程式碼分析警告不會視為錯誤,在以 /WX時。 如需詳細資訊,請參閱/analyze (程式碼分析)。
如 如何:編譯和執行 Automation 物件模型程式碼範例中所述,若要執行該範例,請輸入並執行範例。 然後,在新的 Visual Studio執行個體,請載入 Visual C++ 專案並使用增益集管理員中啟動增益集。
' Add reference to Microsoft.VisualStudio.VCProjectEngine.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio.VCProjectEngine
Imports System.Text
Sub EnablePREfastExample(ByVal dte As DTE2)
Dim prj As VCProject
Dim cfgs, tools As IVCCollection
Dim cfg As VCConfiguration
Dim tool As VCCLCompilerTool
Dim sb As New StringBuilder
prj = CType(dte.Solution.Projects.Item(1).Object, _
Microsoft.VisualStudio.VCProjectEngine.VCProject)
cfgs = CType(prj.Configurations, _
Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
cfg = CType(cfgs.Item(1), _
Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
tool = CType(cfg.Tools("VCCLCompilerTool"), _
Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)
sb.Length = 0
sb.Append("Current project PREfast setting: " _
& tool.EnablePREfast & Environment.NewLine)
sb.Append("Flag: " & tool.AdditionalOptions)
MsgBox(sb.ToString)
' Toggle PREfast setting.
If Not (tool.EnablePREfast = True) Then
' PREfast is not enabled. Turn it and the WX- flag on.
tool.EnablePREfast = True
tool.AdditionalOptions = "/analyze:WX-"
Else
' Toggle the opposite.
tool.EnablePREfast = False
tool.AdditionalOptions = "/analyze:WX"
End If
sb.Length = 0
sb.Append("New project PREfast setting: " _
& tool.EnablePREfast & Environment.NewLine)
sb.Append("Flag: " & tool.AdditionalOptions)
MsgBox(sb.ToString)
End Sub
// Add references to Microsoft.VisualStudio.VCProjectEngine and
// System.Windows.Forms.
using System;
using Extensibility;
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio.VCProjectEngine;
using System.Text;
using System.Windows.Forms;
public void EnablePREfastExample(DTE2 dte)
{
try
{
VCProject prj;
IVCCollection cfgs, tools;
VCConfiguration cfg;
VCCLCompilerTool tool;
StringBuilder sb = new StringBuilder();
prj = (Microsoft.VisualStudio.VCProjectEngine.VCProject)
dte.Solution.Projects.Item(1).Object;
cfgs =
(Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
prj.Configurations;
cfg =
(Microsoft.VisualStudio.VCProjectEngine.VCConfiguration)
cfgs.Item(1);
tools =
(Microsoft.VisualStudio.VCProjectEngine.IVCCollection)
cfg.Tools;
tool =
(Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool)
tools.Item("VCCLCompilerTool");
sb.Length = 0;
sb.Append("Current project PREfast setting: " +
tool.EnablePREfast + Environment.NewLine);
sb.Append("Flag: " + tool.AdditionalOptions);
MessageBox.Show(sb.ToString());
// Toggle PREfast setting.
if (!(tool.EnablePREfast == true))
{
// PREfast is not enabled. Turn it and the WX- flag on.
tool.EnablePREfast = true;
tool.AdditionalOptions = "/analyze:WX-";
}
else
{
// Toggle the opposite.
tool.EnablePREfast = false;
tool.AdditionalOptions = "/analyze:WX";
}
sb.Length = 0;
sb.Append("New project PREfast setting: " +
tool.EnablePREfast + Environment.NewLine);
sb.Append("Flag: " + tool.AdditionalOptions);
MessageBox.Show(sb.ToString());
}
catch (System.Exception errmsg)
{
MessageBox.Show("ERROR! " + errmsg.Message);
}
}
請參閱
參考
Microsoft.VisualStudio.VCProjectEngine 命名空間