Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 910 Bytes

compiler-warning-level-4-c4130.md

File metadata and controls

32 lines (26 loc) · 910 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning (level 4) C4130
Compiler Warning (level 4) C4130
11/04/2016
C4130
C4130
45e4c7b2-6b51-41c7-ba5e-941aa5c7d3dc

Compiler Warning (level 4) C4130

'operator' : logical operation on address of string constant

Using the operator with the address of a string literal produces unexpected code.

The following sample generates C4130:

// C4130.cpp
// compile with: /W4
int main()
{
   char *pc;
   pc = "Hello";
   if (pc == "Hello") // C4130
   {
   }
}

The if statement compares the value stored in the pointer pc to the address of the string "Hello", which is allocated separately each time the string occurs in code. The if statement does not compare the string pointed to by pc with the string "Hello".

To compare strings, use the strcmp function.