Code::Blocks Forums

User forums => Help => Topic started by: yuvadius on August 07, 2012, 05:02:37 pm

Title: how to compile c++11 code
Post by: yuvadius 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.
Title: Re: how to compile c++11 code
Post by: MortenMacFly 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).
Title: Re: how to compile c++11 code
Post by: yuvadius on August 07, 2012, 05:16:19 pm
im a noob i don't know how
Title: Re: how to compile c++11 code
Post by: stahta01 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 (http://wiki.codeblocks.org/index.php?title=FAQ)

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

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

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

Tim S.