2

我正在将现有的 VC12 编译器兼容代码移植到 VC14(Visual Studio 2015),我正面临代码中断问题。

重现问题的示例程序:

#include "iostream"
using namespace std;
#define mybuffer(param)       ((param)->_flag & (_IOMYBUF))

int main()
{
    mybuffer(stderr); // I don't understand what is the purpose of this line.
                      // So, facing issue in replacing this code statement.
    return 0;
}

在 Visual Studio 2013 上:上述程序运行良好。

在 Visual Studio 2015 上:上述程序给出编译错误。

错误 C2039 '_flag':不是 '_iobuf' 的成员

错误 C2065 '_IOMYBUF':未声明的标识符

分析:

在 VS2013 中,wchar.h 有以下内容:

struct _iobuf {
    char *_ptr;
    int   _cnt;
    char *_base;
    int   _flag;
    int   _file;
    int   _charbuf;
    int   _bufsiz;
    char *_tmpfname;
    };
typedef struct _iobuf FILE;

在 VS2015 中,在文件中:corecrt_wstdio.h

#ifndef _FILE_DEFINED
#define _FILE_DEFINED
typedef struct _iobuf
{
    void* _Placeholder;
} FILE;
#endif

您能帮我提出解决上述错误的建议吗?

4

0 回答 0