manav m-n
manav m-n

Reputation: 11394

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?

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

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

cc1plus: error: unrecognized command line option '-std=c++11'

Target: arm-linux-gnueabi

gcc version 4.6.2

Upvotes: 8

Views: 11392

Answers (1)

artless-noise-bye-due2AI
artless-noise-bye-due2AI

Reputation: 22395

Look at cxx0x support matrix. ARM Linux supports most features in a standard way. 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.

Test the define __VERSION__ to see if the compiler can support it. Very, very old Linux versions may have no way to support this with some CPU types; ARMv5 and older. Newer ARM CPUs have some bus locking instructions and can support this with out any or little OS support.

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. However, with more recent Linux versions (and compiler/glibc targeting this version), even the -march=armv5 will work on non-SMP systems. I don't think an ARMv5 SMP system can exist.

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.

For example, with the same compiler but only -march=armv4 versus -march=armv6,

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

#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.

Upvotes: 6

Related Questions