I am writing a program that will use the array container of the C++ Standard Library to hold some objects. However, whenever I try to include the following line of code in my program:
#include <array>
I receive the following error at compile time:
75-143-76-177:soft jeffersonhudson$ g++ mms.cpp -o mms
mms.cpp:5:17: error: array: No such file or directory
75-143-76-177:soft jeffersonhudson$
Commenting out the #include lets me compile just fine. Surely I am overlooking something simple? I have installed the “Command Line Tools” in Xcode, am I still missing something?
EDIT:
I have found the location of array on my computer
/usr/clang-ide/lib/c++/v1
knowing that, what should I do?
<array>is provided in C++11, you need to provide the-std=c++11flag to enable it, and provide the-stdlib=libc++flag for the corresponding library. But the g++ provided by Xcode is so old which doesn’t have much support for C++11. Could you switch to clang?