Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update code::blocks to use TDM-GCC?

Tags:

c++

codeblocks

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!

like image 993
JackHuVandy Avatar asked Dec 15 '22 18:12

JackHuVandy


2 Answers

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]"

like image 115
milleniumbug Avatar answered Jan 07 '23 09:01

milleniumbug


  1. Download the latest tdm-gcc http://tdm-gcc.tdragon.net
  2. Settings->Compiler, Selected Compiler [GNU GCC Compiler] Copy and Create a new configuration [GNU GCC Compiler 4.9.2]
  3. Detail configuration detail configuration image
  4. Set the new compiler configuration as default by click Set as default
  5. Change Compiler settings to having c++11.

PS: code::blocks ver 13.12, tdm-gcc 4.9.2

like image 27
Jichao Avatar answered Jan 07 '23 07:01

Jichao