Reputation: 55
I need to use unique_ptr
in my C++ assignment.
I downloaded a new compiler, TDM-GCC-4.7.1, and installed it. Then I changed the directory of GNU GCC Compiler to the installation path in option: Setting->Compiler...->Toolchain Executable
.
But it doesn't work. When I define a unique_ptr
. A error would occur: "unique pointer is not a command of 'std' "
The reason of using smart pointer is to provide strong exception safety, which is also a requirement of this assignment. I just need to use this new feature of C++11... Plus, the OS I use is Window 7.
Thanks!
Upvotes: 4
Views: 18198
Reputation: 237
That might be a late answer, but for anyone who's asking for that, changing the option "linker for dynamic libs" from gcc to g++ works for me
Upvotes: 0
Reputation: 41805
Set as default
having c++11
.PS: code::blocks ver 13.12, tdm-gcc 4.9.2
Upvotes: 5
Reputation: 15814
In CodeBlocks you can set C++11 mode either in project compiler settings or global compiler settings. Since you may be using it more often, here is how you change it globally:
Go to Settings -> Compiler -> (There should be list of options here, in Compiler flags) -> Select "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]"
Here is how to change it for a single project:
Go to Project -> Build options -> (There should be list of options here, in Compiler flags) -> Select "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]"
Upvotes: 5
Reputation: 3732
#include <memory>
-std=gnu++0x
or -std=c++11
compiler flags......whichever worksUpvotes: 2