|
1 | 1 | ---
|
2 | 2 | description: "Learn more about: /constexpr (Control constexpr evaluation)"
|
3 | 3 | title: "/constexpr (Control constexpr evaluation)"
|
4 |
| -ms.date: "08/15/2017" |
| 4 | +ms.date: 04/14/2025 |
5 | 5 | f1_keywords: ["/constexpr", "-constexpr"]
|
6 | 6 | helpviewer_keywords: ["/constexpr control constexpr evaluation [C++]", "-constexpr control constexpr evaluation [C++]", "constexpr control constexpr evaluation [C++]"]
|
7 |
| -ms.assetid: 76d56784-f5ad-401d-841d-09d1059e8b8c |
8 | 7 | ---
|
9 | 8 | # /constexpr (Control constexpr evaluation)
|
10 | 9 |
|
11 |
| -Use the **/constexpr** compiler options to control parameters for **`constexpr`** evaluation at compile time. |
| 10 | +Use the **`/constexpr`** compiler options to control parameters for **`constexpr`** evaluation at compile time. |
12 | 11 |
|
13 | 12 | ## Syntax
|
14 | 13 |
|
15 |
| -> **/constexpr:depth**<em>N</em>\ |
16 |
| -> **/constexpr:backtrace**<em>N</em>\ |
17 |
| -> **/constexpr:steps**<em>N</em> |
| 14 | +> `/constexpr:depth`<em>N</em>\ |
| 15 | +> `/constexpr:backtrace`<em>N</em>\ |
| 16 | +> `/constexpr:steps`<em>N</em> |
18 | 17 |
|
19 | 18 | ## Arguments
|
20 | 19 |
|
21 |
| -**depth**<em>N</em> |
| 20 | +**`depth`**<em>N</em>\ |
22 | 21 | Limit the depth of recursive **`constexpr`** function invocation to *N* levels. The default is 512.
|
23 | 22 |
|
24 |
| -**backtrace**<em>N</em> |
| 23 | +**`backtrace`**<em>N</em>\ |
25 | 24 | Show up to *N* **`constexpr`** evaluations in diagnostics. The default is 10.
|
26 | 25 |
|
27 |
| -**steps**<em>N</em> |
28 |
| -Terminate **`constexpr`** evaluation after *N* steps. The default is 100,000. |
| 26 | +**`steps`**<em>N</em>\ |
| 27 | +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. |
29 | 28 |
|
30 | 29 | ## Remarks
|
31 | 30 |
|
32 |
| -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++)](../../cpp/constexpr-cpp.md). |
| 31 | +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++)](../../cpp/constexpr-cpp.md). |
33 | 32 |
|
34 |
| -The **/constexpr** options are available beginning in Visual Studio 2015. |
| 33 | +The **`/constexpr`** flag is available beginning in Visual Studio 2015. |
35 | 34 |
|
36 | 35 | ### To set this compiler option in the Visual Studio development environment
|
37 | 36 |
|
38 | 37 | 1. Open your project's **Property Pages** dialog box.
|
39 |
| - |
40 | 38 | 1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
|
41 |
| - |
42 |
| -1. Enter any **/constexpr** compiler options in the **Additional Options** box. Choose **OK** or **Apply** to save your changes. |
| 39 | +1. Enter **/constexpr** compiler options in the **Additional Options** box. Choose **OK** to save your changes. |
43 | 40 |
|
44 | 41 | ### To set this compiler option programmatically
|
45 | 42 |
|
46 | 43 | - See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
|
47 | 44 |
|
48 | 45 | ## See also
|
49 | 46 |
|
50 |
| -[MSVC Compiler Options](compiler-options.md)<br/> |
| 47 | +[MSVC Compiler Options](compiler-options.md)\ |
51 | 48 | [MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
|
0 commit comments