NDK programming on Android Studio2.2, error when logging output to *char string:
Error:format not a string literal and no format arguments [-werror=format-security]
Code:
Online said version is incompatible with the result! The following workarounds are searched:
Workaround:
Modify in your NDK directory build/core/default-build-commands.mk
target_format_string_cflags: =-wformat-werror=format-security
to be
target_format_string_cflags: =-wformat #-werror=format-security
Which is to comment out the back part with the # sign.
Add the following code inside the APPLICATION.MK
App_cppflags + =-wno-error=format-security
It was OK after joining. The compilation passed.
But after this modification, the report runs incorrectly!
Finally, by modifying the code
Put Env->getstringutfchars (name_,0);
Change to:
Env->getstringutfchars (Name_null);
Such as:
Run, pass!
From for notes (Wiz)
Android studio2.2 NDK Error: Format not a string literal and no format arguments!