| description | Learn more about: Warning C26814 | ||
|---|---|---|---|
| title | Warning C26814 | ||
| ms.date | 07/15/2019 | ||
| f1_keywords |
|
||
| helpviewer_keywords |
|
The const variable 'variable' can be computed at compile time. Consider using
constexpr(con.5)
Use constexpr for constants whose value is known at compile time. (Con.5)
Code analysis name: USE_CONSTEXPR_RATHER_THAN_CONST
const int foo = 1234; // C26814 reported here.
constexpr int getMagicNumber()
{
return 42;
}
void bar()
{
const int myval = 3; // C26814 reported here
const int magicNumber = getMagicNumber(); // C26814 reported here.
}Con.5 Use constexpr for all variables that can be computed at compile time