Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 897 Bytes

File metadata and controls

36 lines (27 loc) · 897 Bytes
description Learn more about: Warning C26814
title Warning C26814
ms.date 07/15/2019
f1_keywords
C26814
USE_CONSTEXPR_RATHER_THAN_CONST
helpviewer_keywords
C26814

Warning C26814

The const variable 'variable' can be computed at compile time. Consider using constexpr (con.5)

Remarks

Use constexpr for constants whose value is known at compile time. (Con.5)

Code analysis name: USE_CONSTEXPR_RATHER_THAN_CONST

Example

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.
}

See also

Con.5 Use constexpr for all variables that can be computed at compile time