Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic


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);
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.