解决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...》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

Algorithms to Live By

Algorithms to Live By

Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00

A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具