cocos2d-x-2.1.4:错误:格式不是字符串文字而没有格式参数[-Werror = format-security]

时间:2013-08-23 02:25:58

标签: android cocos2d-iphone android-ndk cocos2d-x

我正在开发一个关于cocos2d-x-2.1.4的游戏,但是,当我尝试在Android上构建它时,它失败并出现错误:格式不是字符串文字而且没有格式参数[-Werror = format-安全性]在文件CCCommon.cpp

然而,当我检查进攻线时,它完全没问题。当我使用Visual Studio和XCode构建WIN32和iOS时,该文件也构建得很好并且总是很好。

错误日志如下:

C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLog(char const*, ...)':
/cygdrive/c/eclipse/android-ndk-r9/build/core/build-binary.mk:348: recipe for target `obj/local/armeabi/objs/cocos2dx_static/platform/android/CCCommon.o' failed
C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp:44:72: error: format not a string literal and no format arguments [-Werror=format-security]
C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp: In function 'void cocos2d::CCLuaLog(char const*)':
make: Leaving directory `/cygdrive/c/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android'
C:/Development/External/cocos2d-2.1rc0-x-2.1.3/projects/Game_C2DX213/proj.android/../../..//cocos2dx/platform/android/CCCommon.cpp:54:77: error: format not a string literal and no format arguments [-Werror=format-security]
cc1plus.exe: some warnings being treated as errors

2 个答案:

答案 0 :(得分:22)

请注意,cocos2d-x-2.1.4可能与ndk-r9不兼容,你试试r8e吗?

您也可以将它放在Application.mk中,以禁止将这些警告视为错误: APP_CFLAGS + = -Wno-error = format-security

此线程中有相同问题的解决方案:

  

http://www.cocos2d-x.org/boards/6/topics/32437?r=33260#message-33260

reference: http://www.cocos2d-x.org/boards/6/topics/33525?r=33579

答案 1 :(得分:12)

你必须在Android.mk中定义以下内容 LOCAL_DISABLE_FORMAT_STRING_CHECKS:= true