简体   繁体   English

如何检查arm-none-linux-gnueabi-g ++对C ++ 11的支持

[英]How to check arm-none-linux-gnueabi-g++ support for C++11

I am writing an portable application which uses C++11 features like std::atomic , std::threads , etc. How do I verify that my ARM GCC cross compiler toolchain supports the C++11 standard? 我正在编写一个使用C++11功能的可移植应用程序,如std::atomicstd::threads等。如何验证我的ARM GCC交叉编译工具链是否支持C++11标准?

I tried using arm-none-linux-gnueabi-g++ -v and arm-none-linux-gnueabi-g++ --version but it returned error when using -std=c++11 我尝试使用arm-none-linux-gnueabi-g++ -varm-none-linux-gnueabi-g++ --version但是在使用-std=c++11时它返回了错误

EDIT # arm-linux-gnueabi-g++ -std=c++11 dum.cpp 编辑 #arm-linux-gnueabi-g ++ -std = c ++ 11 dum.cpp

cc1plus: error: unrecognized command line option '-std=c++11' cc1plus:错误:无法识别的命令行选项'-std = c ++ 11'

Target: arm-linux-gnueabi 目标:arm-linux-gnueabi

gcc version 4.6.2 gcc版本4.6.2

Look at cxx0x support matrix . 看看cxx0x支持矩阵 ARM Linux supports most features in a standard way. ARM Linux以标准方式支持大多数功能。 It is possible that a particular machine may not support a feature. 特定机器可能不支持某项功能。 Ie, the gcc version, linux version and glibc version and CPU type could all come into play. 即, gcc版本, linux版本和glibc版本以及CPU类型都可以发挥作用。

Test the define __VERSION__ to see if the compiler can support it. 测试define __VERSION__以查看编译器是否可以支持它。 Very, very old Linux versions may have no way to support this with some CPU types; 非常非常老的Linux版本可能无法使用某些CPU类型来支持它; ARMv5 and older. ARMv5及更早版本。 Newer ARM CPUs have some bus locking instructions and can support this with out any or little OS support. 较新的ARM CPU具有一些总线锁定指令,并且可以在没有任何或少量操作系统支持的情况下支持此操作。

echo | g++ -dM -E - | grep -i atomic

Should give a list of defines. 应该给出一个定义列表。 If you compile with -march=armv7 , you will have the most luck. 如果使用-march=armv7编译,那么您将获得最大的运气。 However, with more recent Linux versions (and compiler/glibc targeting this version), even the -march=armv5 will work on non-SMP systems. 但是,对于更新的Linux版本(以及针对此版本的编译器/ glibc),即使-march=armv5也适用于非SMP系统。 I don't think an ARMv5 SMP system can exist. 我不认为ARMv5 SMP系统可以存在。

As you can see there are many working parts and it is possible that some features may only be known to work at run time. 正如您所看到的,有许多工作部件,有些功能可能只在运行时才能知道。 It is probably impossible to provide a list; 提供清单可能是不可能的; you need a gcc version with at least the support matrix for it to be possible that the feature works. 你需要一个至少支持矩阵的gcc版本才能使该功能正常工作。

For example, with the same compiler but only -march=armv4 versus -march=armv6 , 例如,使用相同的编译器但只有-march=armv4-march=armv6

armv4 ARMV4

#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1
#define __GCC_ATOMIC_LONG_LOCK_FREE 1
#define __GCC_ATOMIC_POINTER_LOCK_FREE 1
#define __GCC_ATOMIC_INT_LOCK_FREE 1

armv6 的ARMv6

#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
#define __GCC_ATOMIC_INT_LOCK_FREE 2
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
#define __GCC_ATOMIC_LONG_LOCK_FREE 2

Most modern smart phones with have armv7 or better. 大多数具有armv7或更好的现代智能手机。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM