Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 783 Bytes

compiler-warning-level-4-c4189.md

File metadata and controls

34 lines (26 loc) · 783 Bytes
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Compiler Warning (level 3 and level 4) C4189
Compiler Warning (level 3 and level 4) C4189
05/03/2021
C4189
C4189

Compiler Warning (level 3 and level 4) C4189

'identifier' : local variable is initialized but not referenced

A variable is declared and initialized but not used.

Examples

The following sample generates C4189:

// C4189.cpp
// compile with: /W4
int main() {
   int a = 1;   // C4189
}

In Visual Studio 2017 version 15.5 and later, warning C4189 is emitted in more cases, as shown in the following code:

void f() {
    char s[2] = {0}; // C4189
}

To fix the error, remove the unused variable or add the [[maybe_unused]] attribute.