Author Topic: how to compile c++11 code  (Read 5913 times)

Offline yuvadius

  • Single posting newcomer
  • *
  • Posts: 4
how to compile c++11 code
« on: August 07, 2012, 05:02:37 pm »
ok so i started reading a book and it has a section with c++11 features in it.
when i try copy paste the code i get errors.
for example i want to compile this code.
and dont worry i included all headers and those type of stuff.

std::vector<double> vec;
for ( auto& elem : vec )
{
    elem *= 3;
}

but i get all sort of compiler errors.
i google'd this topic and found that i have to turn the flag "-std=c++0x" on,threw progect -> build options
or compiler and debugger.
so i did just that and i still have errors in my code.
i think its because im using the compiler gcc(version 4.4.1 or something like that)
and i need i newer version of gcc compiler.
i tried to install it but it destroyed my codeblocks settings so i had to reinstall codeblocks.
so my compiler can't compile c++11 code.
please help me compile this code.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: how to compile c++11 code
« Reply #1 on: August 07, 2012, 05:11:48 pm »
please help me compile this code.
Install a and setup an appropriate compiler, like GCC/TDM (google for it).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline yuvadius

  • Single posting newcomer
  • *
  • Posts: 4
Re: how to compile c++11 code
« Reply #2 on: August 07, 2012, 05:16:19 pm »
im a noob i don't know how

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: how to compile c++11 code
« Reply #3 on: August 07, 2012, 05:23:37 pm »
im a noob i don't know how

I would suggest using Google to learn to Google; but, I think you would not find it funny.

Read the CB FAQs maybe one will help you.
http://wiki.codeblocks.org/index.php?title=FAQ

Read the CB User Docs
http://wiki.codeblocks.org/index.php?title=User_documentation

http://support.google.com/websearch/bin/answer.py?hl=en&answer=134479

http://tdm-gcc.tdragon.net/

Tim S.
« Last Edit: August 07, 2012, 06:54:46 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org