Android studio2.2 NDK Error: Format not a string literal and no format arguments!

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.