snprintf的宏定义与标准库函数声明冲突



我使用visual studio 2015编译cocos2d-x(3.6版),出现错误,说:

#error: snprintf宏定义与标准库函数声明冲突

几乎和这个链接一样

我试着遵循第一个答案,然后在cocos论坛上搜索大多数结果,但也失败了,我是新手,现在真的不知道…

这是我的源代码在头文件stdio.h中定义了snprintf

#if defined snprintf
    // This definition of snprintf will generate "warning C4005: 'snprintf':     macro
    // redefinition" with a subsequent line indicating where the previous definition
    // of snprintf was.  This makes it easier to find where snprintf was defined.
    #pragma warning(push, 1)
    #pragma warning(1: 4005)
    #define snprintf Do not define snprintf as a macro
    #pragma warning(pop)
    #error Macro definition of snprintf conflicts with Standard Library function declaration
#endif

谁能帮我…谢谢!

我在尝试构建libsndfile-1时得到相同的错误。我通过使用VS2013而不是VS2015来解决这个问题。(我认为应该可以简单地安装VS2013构建工具并从VS2015构建)。

编辑:安装VS2013构建工具集,运行VS2015安装程序并选择'Windows 8.1和Windows Phone 8.0/8.1 Tools'

最新更新