我开始在使用相当复杂的程序的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.
制造:* C:/workspace/c++11_test//obj/local/armeabi/objs/test/test.o错误1
它是ndk-r9。4.8把它搞得很好,只有clang无意中发现了它。我需要定义什么东西才能让clang工作吗?我试过用谷歌搜索错误,但没有任何关联.显然,我可以用-Wno-c++11-narrowing,关闭它,但我不想禁用收缩检查。
它只显示在stlport_static,中,gnustl_static没有错误
发布于 2013-09-03 08:54:42
您似乎已经启用了C++11,因为您收到了此警告。
STLport对C++11的支持不是很好。我怀疑这就是你痛苦的原因。
修复需要更改STLport,或者从clang命令行中移除"-std=c++11“开关。
我建议切换到gnustl (又名gnustl)。( libstdc++),除非有其他原因阻止您这么做(许可: libstdc++是可能对clang有效的GPL3,除了一些重要的例外,也可能不适用于clang您应该自己决定)、遗留支持、大小等)。我在这方面有很好的经验。
https://stackoverflow.com/questions/17901534
复制相似问题