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!
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]"
Set as default
having c++11
.PS: code::blocks ver 13.12, tdm-gcc 4.9.2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With