最近,我将我的IDE从VS2013更改为VS2015。
所有平台工具集都设置为VS2015(v140),我收到错误:
error lnk2001 unresolved external symbol __imp___vsnprintf
我按如下方式添加代码:
#if _MSC_VER>=1900
#define STDC99
extern "C" { FILE __iob_func[3] = { *stdin,*stdout,*stderr }; }
#else
#ifndef snprintf
#define snprintf _snprintf
#endif
#endif
但我仍然会收到如下错误:
cocos2d-x\cocos\platform/win32/CCStdC-win32.h(54): error C4430: missing type specifier
- int assumed. Note: C++ does not support default-int (compiling source file ..\audio\win32
\MciPlayer.cpp)
cocos2d-x\cocos\platform/win32/CCStdC-win32.h(54): error C2143: syntax error: missing ';'
before '{' (compiling source file ..\audio\win32\MciPlayer.cpp)
cocos2d-x\cocos\platform/win32/CCStdC-win32.h(54): error C2146: syntax error: missing ';'
before identifier '__iob_func' (compiling source file ..\audio\win32\MciPlayer.cpp)
cocos2d-x\cocos\platform/win32/CCStdC-win32.h(54): error C2447: '{': missing function
header (old-style formal list?) (compiling source file ..\audio\win32\MciPlayer.cpp)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt\corecrt_wstdio.h(28):
error C2378: 'FILE': redefinition; symbol cannot be overloaded with a typedef
(compiling source file ..\editor-support\cocostudio\CCActionFrameEasing.cpp)
C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt\corecrt_wstdio.h(287):
error C2061: syntax error: identifier 'FILE' (compiling source file ..\base\s3tc.cpp)
在VS2015中:
typedef struct _iobuf
{
void* _Placeholder;
} FILE;
#define stdin (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))
在VS2013中:
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
#define stdin (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])
FILE有两种定义。我怎么能解决它?