You are not logged in.

#1 2014-08-25 20:01:41

Pacopag
Member
Registered: 2011-05-29
Posts: 287

C++: error: ‘std::unique_ptr’ has not been declared

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

#2 2014-08-25 20:14:59

cris9288
Member
Registered: 2013-01-07
Posts: 348

Re: C++: error: ‘std::unique_ptr’ has not been declared

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

#3 2014-08-25 20:19:07

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: C++: error: ‘std::unique_ptr’ has not been declared

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

#4 2014-08-25 20:46:46

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,346

Re: C++: error: ‘std::unique_ptr’ has not been declared

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

Board footer

Powered by FluxBB