Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cocos2d-x-2.1.4 : error: format not a string literal and no format arguments [-Werror=format-security]

I am working on a game on cocos2d-x-2.1.4, however, when I try to build it on Android, it failed with the error: format not a string literal and no format arguments [-Werror=format-security] on the file CCCommon.cpp

However, when I check the offensive line, it is totally fine. The file also build fine and always been fine when I build for WIN32 and iOS with Visual Studio and XCode..

The error log is as follows:

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
like image 444
Jenny Kim Avatar asked Aug 23 '13 02:08

Jenny Kim


2 Answers

Note that cocos2d-x-2.1.4 may not be compatible with ndk-r9, have you try out r8e instead?

You can also put this in your Application.mk to disable treating those warnings as errors: APP_CFLAGS += -Wno-error=format-security

There are more solutions for the same problem in this thread:

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

like image 76
Zennichimaro Avatar answered Oct 18 '22 19:10

Zennichimaro


you have to defice in you Android.mk following LOCAL_DISABLE_FORMAT_STRING_CHECKS := true

like image 42
Tolik Odukha Avatar answered Oct 18 '22 18:10

Tolik Odukha