How can I enable c++0x in a vs-android build

762 Views Asked by At

I am using vs-android (http://code.google.com/p/vs-android) to compile c++ projects for the android platform with the ndk.

It all works well except for when compiling code that uses features from the c++0x/c++11 standard such as std::function, nullptr... I'm assuming, or at least hoping, that I can fix that by adding the compiler option -std=c++0x.

I tried adding that in "Additional options" under "Command line" and some errors seemed to go away but not all of them. Including causes problems, types.h complains about uint64_t not existing and many other similar problems.

Does anyone know how to fix this? There is nothing wrong with the code as it compiles perfectly with msvc10 targeting a windows platform. I am using visual studio 2010.

Thanks

2

There are 2 best solutions below

0
On

vs-android now supports gcc 4.6 which has pretty good c++11 support, and if using -std=gnu++0x instead of -std=c++0x the uint64_t type is defined.

0
On

Even if vs-android is using Visual Studio as the IDE, it is still using gcc 4.4.3 as the compiler (which is released 2.5 years ago). For example, according to http://gcc.gnu.org/projects/cxx0x.html, nullptr is supported only starting from gcc 4.6, so you can't use it.

I don't know about the uint64_t problem. But you'd better stick with C++03 (or even C) for NDK.