News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

how to compile c++11 code

Started by yuvadius, August 07, 2012, 05:02:37 PM

Previous topic - Next topic

yuvadius

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.

MortenMacFly

Quote from: yuvadius on August 07, 2012, 05:02:37 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

yuvadius


stahta01

#3
Quote from: yuvadius on August 07, 2012, 05:16:19 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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]