I’m trying to compile some code (below) using gcc 4.6.2 on OSX 10.6.5. It’s trivial; but the compiler cannot find unique_ptr.
#include <memory>
int main(int argc, char** argv)
{
std::unique_ptr<bar> foo(new bar(0));
}
I compile as such:
c++ main.cpp -o ./bin/main -std=gnu++0x -ansi -pedantic -Wall -Wno-long-long -Wno-deprecated -O3 -ansi -DNDEBUG -I/usr/include -I/opt/local/include
I tried explicitly including bits/unique_ptr but that leads me to an error saying GXX_EXPERIMENTAL_CXX0X is undefined. Huh? As you can see above, I explicitly ask for gnu++0x. I’ve also tried “-std=c++0x” with identical results.
What am I doing wrong?
Your command has
-ansi(which is equivalent to-std=c++98), and this overrides-std=c++0x. Try removing it.