Rediger

Del via


C/C++ Property Pages

The following property pages are found under Project > Properties > Configuration Properties > C/C++:

C/C++ General Properties

Additional Include Directories

Specifies one or more directories to add to the include path. Separate directories with semi-colons (';') if there's more than one. Sets the /I (Additional include directories) compiler option.

Additional #using Directories

Specifies one or more directories to search to resolve names passed to a #using directive. Separate directories with semi-colons (';') if there's more than one. Sets the /AI compiler option.

Additional BMI Directories

Specifies one or more directories to search to resolve names passed to an import directive. Separate directories with semi-colons (';') if there's more than one. Sets the /ifcSearchDir[path] compiler option.

Additional Module Dependencies

Specifies one or more modules to use to resolve names passed to an import directive. Separate directories with semi-colons (';') if there's more than one. Sets the /reference compiler option.

Additional Header Unit Dependencies

Specifies one or more header units to use to resolve names passed to an import header directive. Separate directories with semi-colons (';') if there's more than one. Sets the /headerUnit compiler option.

Scan Sources for Module Dependencies

When set to Yes, the compiler scans all C++ sources, not just module interface and header unit sources, for module and header units dependencies. The build system builds the full dependencies graph, which ensures that all imported modules and header units are built before compiling the files that depend on them. When combined with Translate Includes to Imports, any header file that's specified in a header-units.json file in the same directory as the header file is compiled into a header unit.

Files that have the extension .ixx, and files that have their File properties > C/C++ > Compile As property set to Compile as C++ Header Unit (/exportHeader), are always scanned.

Translate Includes to Imports

When set to Yes, the compiler treats a #include directive as an import directive if certain conditions are met: The header file is specified in a header-units.json file in the same directory, and a compiled header unit (an .ifc file) is available for the header file. Otherwise, the header file is treated as a normal #include. The header-units.json file is used to build header units for each #include without symbol duplication. When combined with Scan Sources for Module Dependencies, the compiler automatically finds all of the header files that can be compiled into header units. This property sets the /translateInclude compiler option.

Debug Information Format

Specifies the type of debugging information generated by the compiler. This property requires compatible linker settings. Sets /Z7, /Zi, /ZI (Debug information format) compiler options.

Choices

  • None - Produces no debugging information, so compilation may be faster.
  • C7 compatible - Select the type of debugging information created for your program and whether this information is kept in object (.obj) files or in a program database (PDB).
  • Program Database - Produces a program database (PDB) that contains type information and symbolic debugging information for use with the debugger. The symbolic debugging information includes the names and types of variables and functions, and line numbers.
  • Program Database for Edit And Continue - Produces a program database, as described previously, in a format that supports the Edit and Continue feature.

Support Just My Code Debugging

Adds supporting code for enabling Just My Code debugging in this compilation unit. Sets /JMC.

Common Language RunTime Support

Use the .NET runtime service. This switch is incompatible with some other switches; see the documentation on the /clr family of switches for details.

Choices

  • No Common Language RunTime Support - No Common Language RunTime Support
  • Common Language RunTime Support - Creates metadata for your application that can be consumed by other CLR applications. Also allows your application to consume types and data in the metadata of other CLR components.
  • Pure MSIL Common Language RunTime Support - Produces an MSIL-only output file with no native executable code, although it can contain native types compiled to MSIL.
  • Safe MSIL Common Language RunTime Support - Produces an MSIL-only (no native executable code) and verifiable output file.

Consume Windows Runtime Extension

Consume the Windows Run Time languages extensions. Sets /ZW.

Suppress Startup Banner

Suppresses the display of the sign-on banner when the compiler starts up and display of informational messages during compiling.

Warning Level

Select how strict you want the compiler to be about code errors. Sets /W0 - /W4.

Choices

  • Turn Off All Warnings - Level 0 disables all warnings.
  • Level1 - Level 1 displays severe warnings. Level 1 is the default warning level at the command line.
  • Level2 - Level 2 displays all level 1 warnings and warnings less severe than level 1.
  • Level3 - Level 3 displays all level 2 warnings and all other warnings recommended for production purposes.
  • Level4 - Level 4 displays all level 3 warnings plus informational warnings, which in most cases can be safely ignored.
  • EnableAllWarnings - Enables all warnings, including the ones disabled by default.

Treat Warnings As Errors

Treats compiler warnings as errors. For a new project, it may be best to use /WX in every compilation. Resolve all warnings to minimize hard-to-find code defects.

Warning Version

Hide warnings introduced after a specific version of the compiler. Sets /Wv:xx[.yy[.zzzzz]].

Diagnostics Format

Enables rich diagnostics, with column information and source context in diagnostic messages.

Choices

  • Caret - Provides column information in the diagnostic message. And, outputs the relevant line of source code with a caret that indicates the offending column.
  • Column Info - Additionally provides the column number within the line where the diagnostic is issued, where applicable.
  • Classic - Outputs only the prior, concise diagnostic messages with the line number.

SDL checks

Additional Security Development Lifecycle (SDL) recommended checks; includes enabling additional secure code generation features and enables extra security-relevant warnings as errors. Sets /sdl, /sdl-.

Multi-processor Compilation

Enable multi-processor compilation. Sets the /MP compiler option.

Enable Address Sanitizer

Compiles and links the program with AddressSanitizer instrumentation. This property currently supports x86 and x64 target builds. Sets the /fsanitize compiler option.

C/C++ Optimization Properties

Optimization

Select option for code optimization; choose Custom to use specific optimization options. Sets /Od, /O1, /O2.

Choices

  • Custom - Custom optimization.
  • Disabled - Disable optimization.
  • Maximum Optimization (Favor Size) - Equivalent to /Os /Oy /Ob2 /Gs /GF /Gy
  • Maximum Optimization (Favor Speed) - Equivalent to /Oi /Ot /Oy /Ob2 /Gs /GF /Gy
  • Optimizations (Favor Speed) - Equivalent to /Oi /Ot /Oy /Ob2

Inline Function Expansion

Select the level of inline function expansion for the build. Sets /Ob.

Choices

  • Default
  • Disabled - Disables inline expansion, which is on by default.
  • Only __inline - Expands only functions marked as inline, __forceinline, or __inline. Or, in a C++ member function, defined within a class declaration.
  • Any Suitable - Expands functions marked as inline or __inline and any other function that the compiler chooses. (Expansion occurs at the compiler's discretion, often referred to as autoinlining.)

Enable Intrinsic Functions

Enables intrinsic functions. Using intrinsic functions generates faster, but possibly larger, code. Sets /Oi.

Favor Size Or Speed

Whether to favor code size or code speed; 'Global Optimization' must be turned on. Sets /Ot, /Os.

Choices

  • Favor small code - Minimizes the size of EXEs and DLLs by instructing the compiler to favor size over speed.
  • Favor fast code - Maximizes the speed of EXEs and DLLs by instructing the compiler to favor speed over size. (This value is the default.)
  • Neither - No size and speed optimization.

Omit Frame Pointers

Suppresses creation of frame pointers on the call stack.

Enable Fiber-Safe Optimizations

Enables memory space optimization when using fibers and thread local storage access. Sets /GT.

Whole Program Optimization

Enables cross-module optimizations by delaying code generation to link time. Requires the linker option Link Time Code Generation. Sets /GL.

C/C++ Preprocessor Properties

Preprocessor Definitions

Defines preprocessing symbols for your source file.

Undefine Preprocessor Definitions

Specifies one or more preprocessor undefines. Sets /U.

Undefine All Preprocessor Definitions

Undefine all previously defined preprocessor values. Sets /u.

Ignore Standard Include Paths

Prevents the compiler from searching for include files in directories specified in the INCLUDE environment variables.

Preprocess to a File

Preprocesses C and C++ source files, and writes the preprocessed output to a file. This option suppresses compilation, and it doesn't produce an .obj file.

Preprocess Suppress Line Numbers

Preprocess without #line directives.

Keep Comments

Suppresses comment strip from source code; requires setting at least one of the Preprocessing options. Sets /C.

C/C++ Code Generation Properties

Enable String Pooling

The compiler creates only one read-only copy of identical strings in the program image. It results in smaller programs, an optimization called string pooling. /O1, /O2, and /ZI automatically set /GF option.

Enable Minimal Rebuild

Enables minimal rebuild, which determines whether to recompile C++ source files that include changed C++ class definitions, stored in header .h files.

Enable C++ Exceptions

Specifies the model of exception handling to be used by the compiler.

Choices

  • Yes with SEH Exceptions - The exception-handling model that catches asynchronous (structured) and synchronous (C++) exceptions. Sets /EHa.
  • Yes - The exception-handling model that catches C++ exceptions only and tells the compiler to assume that extern C functions never throw a C++ exception. Sets /EHsc.
  • Yes with Extern C functions - The exception-handling model that catches C++ exceptions only and tells the compiler to assume that extern C functions do throw an exception. Sets /EHs.
  • No - No exception handling.

Smaller Type Check

Enable checking for conversion to smaller types, incompatible with any optimization type other than debug. Sets /RTCc.

Basic Runtime Checks

Enable basic runtime error checks, incompatible with any optimization type other than debug. Sets /RTCs, /RTCu, /RTC1.

Choices

  • Stack Frames - Enables stack frame run-time error checking.
  • Uninitialized variables - Reports when a variable is used without having been initialized.
  • Both (/RTC1, equiv. to /RTCsu) - Equivalent of /RTCsu.
  • Default - Default runtime checks.

Runtime Library

Specify runtime library for linking. Sets /MT, /MTd, /MD, /MDd.

Choices

  • Multi-threaded - Causes your application to use the multithread, static version of the run-time library.
  • Multi-threaded Debug - Defines _DEBUG and _MT. This option also causes the compiler to place the library name LIBCMTD.lib into the .obj file so that the linker will use LIBCMTD.lib to resolve external symbols.
  • Multi-threaded DLL - Causes your application to use the multithread- and DLL-specific version of the run-time library. Defines _MT and _DLL and causes the compiler to place the library name MSVCRT.lib into the .obj file.
  • Multi-threaded Debug DLL - Defines _DEBUG, _MT, and _DLL and causes your application to use the debug multithread- and DLL-specific version of the run-time library. It also causes the compiler to place the library name MSVCRTD.lib into the .obj file.

Struct Member Alignment

Specifies 1, 2, 4, or 8-byte boundaries for struct member alignment. Sets /Zp.

Choices

  • 1 Byte - Packs structures on one-byte boundaries. Same as /Zp.
  • 2 Bytes - Packs structures on two-byte boundaries.
  • 4 Bytes - Packs structures on four-byte boundaries.
  • 8 Bytes - Packs structures on eight-byte boundaries (default).
  • 16 Bytes - Packs structures on sixteen-byte boundaries.
  • Default - Default alignment settings.

Security Check

The Security Check helps detect stack-buffer over-runs, a common attempted attack upon a program's security.

Choices

  • Disable Security Check - Disable Security Check. Sets /GS-.
  • Enable Security Check - Enable Security Check. Sets /GS.

Control Flow Guard

Guard security check helps detect attempts to dispatch to illegal block of code.

Choices

  • Yes - Enable Security Check with Guard Sets /guard:cf.
  • No

Enable Function-Level Linking

Allows the compiler to package individual functions in the form of packaged functions (COMDATs). Required for edit and continue to work. Sets /Gy.

Enable Parallel Code Generation

Allows the compiler to generate parallel code for loops identified using #pragma loop(hint_parallel[(n)]) when optimization is enabled.

Enable Enhanced Instruction Set

Enable use of instructions found on processors that support enhanced instruction sets. For example, the SSE, SSE2, AVX, and AVX2 enhancements to IA-32. And, the AVX and AVX2 enhancements to x64. Currently /arch:SSE and /arch:SSE2 are only available when building for the x86 architecture. If no option is specified, the compiler uses instructions found on processors that support SSE2. Use of enhanced instructions can be disabled with /arch:IA32. For more information, see /arch (x86), /arch (x64), /arch (ARM64), and /arch (ARM).

Choices

  • Streaming SIMD Extensions - Streaming SIMD Extensions. Sets /arch:SSE
  • Streaming SIMD Extensions 2 - Streaming SIMD Extensions 2. Sets /arch:SSE2
  • Advanced Vector Extensions - Advanced Vector Extensions. Sets /arch:AVX
  • Advanced Vector Extensions 2 - Advanced Vector Extensions 2. Sets /arch:AVX2
  • No Enhanced Instructions - No Enhanced Instructions. Sets /arch:IA32
  • Not Set - Not Set.

Floating Point Model

Sets the floating point model. Sets /fp:precise, /fp:strict, /fp:fast.

Choices

  • Precise - Default. Improves the consistency of floating-point tests for equality and inequality.
  • Strict - The strictest floating-point model. /fp:strict causes fp_contract to be OFF and fenv_access to be ON. /fp:except is implied and can be disabled by explicitly specifying /fp:except-. When used with /fp:except-, /fp:strict enforces strict floating-point semantics but without respect for exceptional events.
  • Fast - Creates the fastest code in most cases.

Enable Floating Point Exceptions

Reliable floating-point exception model. Exceptions will be raised immediately after they're triggered. Sets /fp:except.

Create Hotpatchable Image

When hotpatching is on, the compiler ensures that first instruction of each function is two bytes, as required for hot patching. Sets /hotpatch.

Spectre Mitigation

Spectre mitigations for CVE 2017-5753. Sets /Qspectre.

Choices

  • Enabled - Enable Spectre mitigation feature for CVE 2017-5753
  • Disabled - Not Set.

C/C++ Language Properties

Disable Language Extensions

Suppresses or enables language extensions. Sets /Za.

Treat WChar_t As Built in Type

When specified, the type wchar_t becomes a native type that maps to __wchar_t in the same way that short maps to __int16. /Zc:wchar_t is on by default.

Force Conformance in For Loop Scope

Implements standard C++ behavior for the for statement loops with Microsoft extensions. Sets /Za, /Ze (Disable language extensions. /Zc:forScope is on by default.

Remove unreferenced code and data

When specified, the compiler no longer generates symbol information for unreferenced code and data.

Enforce type conversion rules

Used to identify an rvalue reference type as the result of a cast operation according to the C++11 standard.

Enable Run-Time Type Information

Adds code for checking C++ object types at run time (runtime type information, or RTTI). Sets /GR, /GR-.

Open MP Support

Enables OpenMP 2.0 language extensions. Sets /openmp.

C++ Language Standard

Determines the C++ language standard that the compiler enables. The default value doesn't set a standard option, so the compiler uses its default C++14 setting. If you select a specific value, the corresponding /std compiler option is set.md).

Choices

  • Default (ISO C++14 Standard)
  • ISO C++14 Standard (/std:c++14)
  • ISO C++17 Standard (/std:c++17)
  • ISO C++20 Standard (/std:c++20)
  • Preview - Features from the Latest C++ Working Draft (/std:c++latest)

C Language Standard

Determines the C language standard that the compiler enables. The default value doesn't set a standard option, so the compiler uses its default legacy MSVC setting. If you select a specific value, the corresponding /std compiler option is set.md).

Choices

  • Default (Legacy MSVC)
  • ISO C11 Standard (/std:c11)
  • ISO C17 (2018) Standard (/std:c17)

Conformance mode

Enables or suppresses conformance mode. Sets /permissive-.

Enable Experimental C++ Standard Library Modules

Experimental support for the C++ Modules TS and Standard Library modules.

Build ISO C++23 Standard Library Modules

Starting in Visual Studio 17.6, when this property is enabled and C++ Language Standard is set to /std:c++latest, Visual C++ projects automatically find and build ISO C++23 Standard Library modules. This enables you to import std or import std.compat in your C++ code.

C/C++ Precompiled Headers Properties

Create/Use Precompiled Header

Enables creation or use of a precompiled header during the build. Sets /Yc, /Yu.

Choices

  • Create - Instructs the compiler to create a precompiled header (.pch) file that represents the state of compilation at a certain point.
  • Use - Instructs the compiler to use an existing precompiled header (.pch) file in the current compilation.
  • Not Using Precompiled Headers - Not using precompiled headers.

Precompiled Header File

Specifies header file name to use when creating or using a precompiled header file. Sets /Yc, /Yu.

Precompiled Header Output File

Specifies the path or name of the generated precompiled header file. Sets /Fp.

C/C++ Output Files Properties

Expand Attributed Source

Create listing file with expanded attributes injected into source file. Sets /Fx.

Assembler Output

Specifies the contents of assembly language output file. Sets /FA, /FAc, /FAs, /FAcs.

Choices

  • No Listing - No listing.
  • Assembly-Only Listing - Assembly code; .asm
  • Assembly With Machine Code - Machine and assembly code; .cod
  • Assembly With Source Code - Source and assembly code; .asm
  • Assembly, Machine Code and Source - Assembly, machine code and source code; .cod

Use Unicode For Assembler Listing

Causes the output file to be created in UTF-8 format.

ASM List Location

Specifies relative path or name for ASM listing file; can be file or directory name. Sets /Fa.

Object File Name

Specifies a name to override the default object file name; can be file or directory name. Sets /Fo.

Program Database File Name

Specifies a name for a compiler-generated PDB file; also specifies base name for the required compiler-generated IDB file; can be file or directory name. Sets /Fd.

Generate XML Documentation Files

Specifies that the compiler should generate XML documentation comment files (.XDC). Sets /doc.

XML Documentation File Name

Specifies the name of the generated XML documentation files; can be file or directory name. Sets /doc:<name>.

C/C++ Browse Information Properties

Enable Browse Information

Specifies level of browse information in .bsc file. Sets /FR.

Browse Information File

Specifies optional name for browser information file. Sets /FR<name>.

External Includes

Treat Files Included with Angle Brackets as External

Specifies whether to treat files included with angle brackets as external. Set this property to Yes to set the /external:anglebrackets compiler option.

External Header Warning Level

Select how strict you want the compiler to be about code errors in external headers. This property sets the /external:Wn compiler option. If this value is set to Inherit Project Warning Level or the default, other /external options are ignored.

Template Diagnostics in External Headers

Specifies whether to evaluate the warning level across a template instantiation chain. Set this property to Yes to set the /external:templates- compiler option.

Disable Code Analysis for External Headers

Disables code analysis for external headers. Sets the /analyze:external- compiler option.

Analysis Ruleset for External Headers

Specifies a code analysis ruleset override for external headers. If not specified, the Code Analysis setting is used. Sets the /analyze:external:ruleset path compiler option.

C/C++ Advanced Properties

Calling Convention

Select the default calling convention for your application (can be overridden by function). Sets /Gd, /Gr, /Gz, /Gv.

Choices

  • __cdecl - Specifies the __cdecl calling convention for all functions except C++ member functions and functions marked __stdcall or __fastcall.
  • __fastcall - Specifies the __fastcall calling convention for all functions except C++ member functions and functions marked __cdecl or __stdcall. All __fastcall functions must have prototypes.
  • __stdcall - Specifies the __stdcall calling convention for all functions except C++ member functions and functions marked __cdecl or __fastcall. All __stdcall functions must have prototypes.
  • __vectorcall - Specifies the __vectorcall calling convention for all functions except C++ member functions and functions marked __cdecl, __fastcall, or __stdcall. All __vectorcall functions must have prototypes.

Compile As

Select compile language option for source files. Sets /TC, /TP, /interface, /internalPartition, or /exportHeader options.

Choices

  • Default - Default.
  • Compile as C Code (/TC) - Compile specified source files as C code. By default, files with a .c extension are compiled as C.
  • Compile as C++ Code (/TP) - Compile specified source files as C++ code. By default, all source files that don't have a .c, .ixx, .cppm, .h, or no extension are compiled as C++.
  • Compile as C++ Module Code (/interface) - Compile specified source files as C++ module code. By default, files with a .ixx or .cppm extension are compiled as C++ module code.
  • Compile as C++ Module Internal Partition (/internalPartition) - Compile specified source files as C++ module internal partition.
  • Compile as C++ Header Unit (/exportHeader) - Compile specified source files as C++ header unit. By default, files with a .h extension or no extension are compiled as header units.

Disable Specific Warnings

Disable the specified warning numbers. Put the warning numbers in a semi-colon delimited list. Sets /wd<number>.

Forced Include File

one or more forced include files. Sets /FI<name>.

Forced #using File

Specifies one or more forced #using files. Sets /FU<name>.

Show Includes

Generates a list of include files with compiler output. Sets /showIncludes.

Use Full Paths

Use full paths in diagnostic messages. Sets /FC.

Omit Default Library Name

Doesn't include default library names in .obj files. Sets /Zl.

Internal Compiler Error Reporting

Note

This option is deprecated. Starting in Windows Vista, error reporting is controlled by Windows Error Reporting (WER) settings.

Treat Specific Warnings As Errors

Treats the specific compiler warning as an error where n is a compiler warning.

Additional Options

Additional Options.