解决Android Studio 3.2.1中NDK编译代码时候出现警告": warning: conflicts with previous declar...

栏目: C++ · 发布时间: 7年前

解决Android Studio 3.2.1中NDK编译代码时候出现警告" : warning: conflicts with previous declaration here [-Wattributes]"

在使用 Android Studio 3.2.1 结合 NDK r16/r18 编译代码时候出现如下警告:

<built-in>: In function 'float abs(float)':
<built-in>: warning: conflicts with previous declaration here [-Wattributes]

关键是出现警告的代码文件中并不一定存在 abs 函数的调用。

这个警告产生的条件是在编译器中指定了 STL ,并且指定编译器为 GCC ,调用的源代码文件中恰好有 STL 的代码。

类似如下:

externalNativeBuild {
    cmake {
        cppFlags "-DANDROID_ARM_NEON=TRUE", "-DANDROID_TOOLCHAIN=gcc", "-DANDROID_PLATFORM=android-21", "-DANDROID_STL=c++_static"
        abiFilters 'armeabi-v7a'
    }
}

原因在于新版本的 NDK r16/r18 中,对于 GCC 部分的适配已经不是非常完善了,已经逐步迁移到 CLANG(LLVM) 了。导致 STL 进行编译的时候,会出现一些警告信息。这个警告信息是 STL 库的警告信息,跟我们自己的代码没有关系。

只需要指定 " -DANDROID_TOOLCHAIN=clang " 即可解决这个问题。

参考链接

NDK r13, -fexceptions -Wall --> warning: conflicts with previous declaration


以上所述就是小编给大家介绍的《解决Android Studio 3.2.1中NDK编译代码时候出现警告": warning: conflicts with previous declar...》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Practical Algorithms for Programmers

Practical Algorithms for Programmers

Andrew Binstock、John Rex / Addison-Wesley Professional / 1995-06-29 / USD 39.99

Most algorithm books today are either academic textbooks or rehashes of the same tired set of algorithms. Practical Algorithms for Programmers is the first book to give complete code implementations o......一起来看看 《Practical Algorithms for Programmers》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码