Android ndk 在Android项目中禁止使用静态断言 我正在向Android中移植一些C++代码。其中一个源文件包含在编译过程中导致错误的webrtc头文件。我已将问题简化为以下简单代码: template <class T, int n> struct DefaultDeleter<T[n]> { // Never allow someone to declare something like scoped_ptr<int[10]>. static_assert(sizeof(T) == -1, "do not use array with size as type"); }; 模板 结构默认删除程序{ //决不允许有人声明类似范围的内容。 静态_断言(sizeof(T)=-1,“不要使用大小为类型的数组”); };

Android ndk 在Android项目中禁止使用静态断言 我正在向Android中移植一些C++代码。其中一个源文件包含在编译过程中导致错误的webrtc头文件。我已将问题简化为以下简单代码: template <class T, int n> struct DefaultDeleter<T[n]> { // Never allow someone to declare something like scoped_ptr<int[10]>. static_assert(sizeof(T) == -1, "do not use array with size as type"); }; 模板 结构默认删除程序{ //决不允许有人声明类似范围的内容。 静态_断言(sizeof(T)=-1,“不要使用大小为类型的数组”); };,android-ndk,Android Ndk,我得到的错误是: [armeabi-v7a] Compile++ thumb: dummyclient <= dummy.cpp dummy.cpp:7:3: warning: identifier 'static_assert' will become a keyword in C++0x [-Wc++0x-compat] dummy.cpp:5:8: error: 'DefaultDeleter' is not a template dummy.cpp:7:17: error: exp

我得到的错误是:

[armeabi-v7a] Compile++ thumb: dummyclient <= dummy.cpp
dummy.cpp:7:3: warning: identifier 'static_assert' will become a keyword in C++0x [-Wc++0x-compat]
dummy.cpp:5:8: error: 'DefaultDeleter' is not a template
dummy.cpp:7:17: error: expected identifier before 'sizeof'
dummy.cpp:7:17: error: expected ',' or '...' before 'sizeof'
dummy.cpp:7:70: error: ISO C++ forbids declaration of 'static_assert' with no type [-fpermissive]

[armeabi-v7a]Compile++thumb:dummyclient您需要传递CPPFLAG
-std=c++11