mardi 24 mars 2015

OS X 10.10 compiler stopped using C++ 11 by default

I have a MacBook Pro running OS X 10.10 with the following clang version:



Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)



Up until a few hours ago, compiling C++ code tried using C++11 by default, as it should have. I was trying to compile some older code, so I followed this advice and executed the command



export MACOSX_DEPLOYMENT_TARGET=10.8



Sure enough, compilations from the same terminal window then used the older C++ standard.


Now I can't get back to C++ 11! I closed the terminal window and even restarted the machine, and yet - the default is stdc++ and not c++11!



echo $MACOSX_DEPLOYMENT_TARGET



displays nothing, of course.


Here is my C++ file, appropriately called problem.cpp:



#include <vector>
#include <string>
std::vector<std::string> ELEMENTS = {"A", "B", "C"};


Compiling with c++ -std=c++11 -c problem.cpp works well.


Compiling with c++ -c problem.cpp fails because of the initialization of ELEMENTS.


Aucun commentaire:

Enregistrer un commentaire