You are not logged in.
Hi. I'm trying to compile some C++ code (that I didn't write) and I keep getting this error
error: ‘std::unique_ptr’ has not been declared
I've just got all my .h and .cpp files in one folder, and from there I'm trying
g++ -std=c++11 *.cpp
I know this probably looks bad, but I don't have a makefile.
The real point is, why doesn't gcc recognize unique_ptr when I'm explicitly specifying to g++ to use c++11?
Offline
Did you #include<memory> ? Perhaps I'm wrong, but this page seems to think it is necessary. http://en.cppreference.com/w/cpp/memory/unique_ptr
Offline
A grep on it turns up nothing, so I don't think that's included anywhere.
I've seen it with my own eyes that this project builds successfully as is in xcode on a mac.
Offline
IIRC, xcode does not use gcc by default; the libraries would be different implementation. I realize we are talking about std:: here, but perhaps the header files have a different hierarchy. That, or Xcode is pulling some slight of hand and helping you without asking.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline