VCCLCompilerTool.AdditionalOptions Property

Definition

Gets or sets options to add to the end of the command line immediately before the file name(s). An example is if an option is not supported in the object model.

C++/CX
public:
 property Platform::String ^ AdditionalOptions { Platform::String ^ get(); void set(Platform::String ^ value); };

Property Value

Options added to the end of the command line immediately before the file name(s)

Attributes

Examples

The following example demonstrates how to use the EnablePREfast and AdditionalOptions properties to set the /analyze:WX- switch. (Both properties are required to do this.) Specifying /analyze:WX- means that code analysis warnings will not be treated as errors when compiling with /WX. For more information, see /analyze (Code Analysis).

VB
' 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  

Applies to

Product Versions
Visual Studio SDK 2015, 2017, 2019, 2022