gpt4 book ai didi

Android - NDK 奇怪的错误

转载 作者:太空狗 更新时间:2023-10-29 15:09:46 25 4
gpt4 key购买 nike

我开始在相当复杂的程序中遇到 NDK 的有趣错误:

#include <stdio.h>
#include <iostream>

int main( int argc, char **argv ) {
return 0;
}


>call c:\android-ndk-r9\ndk-build.cmd
"Compile++ thumb : test <= test.cpp
In file included from C:/workspace/c++11_test//jni/test.cpp:11:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\iostream:43:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_istream.h:31:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_ostream.h:380:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_ostream.c:26:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_num_put.h:180:
In file included from c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_num_put.c:26:
c:/android-ndk-r9/sources/cxx-stl/stlport/stlport\stl/_limits.h:217:48: error: non-type template argument evaluates to -2147483648, which cannot be narrowed to type 'wchar_t'
[-Wc++11-narrowing]
: public _STLP_PRIV _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX, -1, true>
^
c:/android-ndk-r9/platforms/android-14/arch-arm/usr/include\../include/wchar.h:76:22: note: expanded from macro 'WCHAR_MIN'
#define WCHAR_MIN INT_MIN
^
c:/android-ndk-r9/platforms/android-14/arch-arm/usr/include\sys/limits.h:69:18: note: expanded from macro 'INT_MIN'
#define INT_MIN (-0x7fffffff-1) /* min value for an int */
^
1 error generated.

make: * [C:/workspace/c++11_test//obj/local/armeabi/objs/test/test.o]错误1

它是 ndk-r94.8 编译得很好,只有 clang 偶然发现了它。我需要定义一些东西来让 clang 工作吗?我试过谷歌错误,但没有任何相关......显然,我可以使用 -Wno-c++11-narrowing 将其关闭,但我不想禁用缩小检查。

而且它只显示STLport_staticgnuSTL_static没有错误

最佳答案

您似乎已启用 C++11,因为您收到此警告。

STLport 对 C++11 的支持不是很好。我怀疑这是你的困境的原因。

修复需要更改 STLport,或从 clang 命令行中删除“-std=c++11”开关。

恕我直言,我建议切换到 gnuSTL(又名 libstdc++),除非有其他原因阻止你这样做(许可:libstdc++ 是 GPL3 with some significant exceptions,它可能对 clang 有效,也可能无效 - 你应该确定为你自己),传统支持,大小等)。我在这方面有很好的经验。

关于Android - NDK 奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17901534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com