LLVM & Clang support for C ++ 11

I have code I wrote for MS VC ++ 10. I use C ++ 11 and, in particular, expressions like

std::function<int (int)> f =...; auto it = v.begin(); for_each(it1, it2,[&](int& i) { ++i;}); 

Now I am testing MacOS and Xcode with llvm & clang, and my code cannot be compiled! The question is why? Perhaps I will indicate a use case for C ++ 11. In this case, where can I fix this in xcode?

+4
source share
2 answers

You will need Xcode 4.2.

In the build settings, find "C ++ 0x" and set the "C ++ Language Dialog to C ++ 0x [-std = C ++ 0x]". Then find "libC ++" and set the "C ++ Standard Library" to "libC ++".

Not all C ++ 11 features are available. For example, lambdas are not yet supported.

+14
source

For a list of the C ++ 11 features that Clang currently supports, see this nice list . Lambda expressions (and syntactically linked initialization lists) are not currently implemented.

Your only choice at the moment (as long as Clang devs does not implement lambda support) uses the GCC 4.5 / 4.6 MacPorts compilers.

An additional command line parameter will be -std=c++0x (in the next version of Clang and GCC, it will be correct -std=c++11 ).

+5
source

Source: https://habr.com/ru/post/1379314/


All Articles