VS2010上不区分大小写的字符串比较-为每个版本的VS播放#if定义的语句

Case-insensitive string comparison on VS2010 - playing with #if defined statements for each version of VS

本文关键字:VS 版本 播放 语句 定义 #if 不区 大小写 字符串 VS2010 比较      更新时间:2023-10-16

我正在将一些旧代码转换为Visual Studio 2010项目,下面的代码给了我错误。。。

#if _MSC_VER >= 1200 || defined __BORLANDC__
#define cv_stricmp stricmp
#define cv_strnicmp strnicmp
#if defined WINCE
#define strdup _strdup
#define stricmp _stricmp
#endif
#elif defined __GNUC__ || defined __sun
#define cv_stricmp strcasecmp
#define cv_strnicmp strncasecmp
#else
#error Do not know how to make case-insensitive string comparison on this platform
#endif

我不知道如何在VisualStudio2010中采用这些语句。我怎么能这么做?

我想你不是说#error被击中,因为VC 2010不会发生这种情况。

如果您指的是弃用警告,请尝试使用_stricmp_strnicmp

#if _MSC_VER >= 1200 || defined __BORLANDC__
    #if _MSC_VER >= 1400
        #define cv_stricmp _stricmp
        #define cv_strnicmp _strnicmp
    #else
        #define cv_stricmp stricmp
        #define cv_strnicmp strnicmp
`   #endif
    #if defined WINCE
        #define strdup _strdup
        #define stricmp _stricmp
    #endif
#elif defined __GNUC__ || defined __sun
    #define cv_stricmp strcasecmp
    #define cv_strnicmp strncasecmp
#else
    #error Do not know how to make case-insensitive string comparison on this platform
#endif