Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize


warning C6400: Using <function name> to perform a case-insensitive compare to constant string <string name>. Yields unexpected results in non-English locales

This warning indicates that a case-insensitive comparison to a constant string is being performed in a locale-dependent way, when, apparently, a locale-independent comparison was intended.

The typical consequence of this defect is incorrect behavior in non-English speaking locales. For example, in Turkish, ".gif" will not match ".GIF"; in Vietnamese, "LogIn" will not match "LOGIN".

String comparisons should typically be performed with the CompareString function. To perform a locale-independent comparison on Windows XP, the first parameter should be the constant LOCALE_INVARIANT.

The following code generates this warning:

#include <windows.h>
int f(char *ext)
  // code...
  return (lstrcmpi(ext, TEXT("gif")) == 0);

To correct this warning, perform a locale-independent test for whether char *ext matches "gif" ignoring upper/lower case differences, use the following code:

#include <windows.h>
int f(char *ext)
  // code...
  return (CompareString(
                        TEXT ("gif"),
                        -1) == CSTR_EQUAL);
© 2015 Microsoft