Skip to content

Latest commit

 

History

History
48 lines (32 loc) · 2.21 KB

constexpr-control-constexpr-evaluation.md

File metadata and controls

48 lines (32 loc) · 2.21 KB
description title ms.date f1_keywords helpviewer_keywords
Learn more about: /constexpr (Control constexpr evaluation)
/constexpr (Control constexpr evaluation)
04/14/2025
/constexpr
-constexpr
/constexpr control constexpr evaluation [C++]
-constexpr control constexpr evaluation [C++]
constexpr control constexpr evaluation [C++]

/constexpr (Control constexpr evaluation)

Use the /constexpr compiler options to control parameters for constexpr evaluation at compile time.

Syntax

/constexpr:depthN
/constexpr:backtraceN
/constexpr:stepsN

Arguments

depthN
Limit the depth of recursive constexpr function invocation to N levels. The default is 512.

backtraceN
Show up to N constexpr evaluations in diagnostics. The default is 10.

stepsN
Terminate constexpr evaluation after N steps. The default is 100,000. A step refers to an individual computation taken towards evaluating the constant expression. Increasing the maximum number of steps might cause compilation to take longer in cases where compilation would otherwise fail.

Remarks

The /constexpr compiler options control compile-time evaluation of constexpr expressions. Evaluation steps, recursion levels, and backtrace depth are controlled to prevent the compiler from spending too much time on constexpr evaluation. For more information on the constexpr language element, see constexpr (C++).

The /constexpr flag is available beginning in Visual Studio 2015.

To set this compiler option in the Visual Studio development environment

  1. Open your project's Property Pages dialog box.
  2. Select the Configuration Properties > C/C++ > Command Line property page.
  3. Enter /constexpr compiler options in the Additional Options box. Choose OK to save your changes.

To set this compiler option programmatically

  • See xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A.

See also

MSVC Compiler Options
MSVC Compiler Command-Line Syntax