Sunday, March 31, 2013

Lambda Expression Only Available With -std=c++0x or -std=gnu++0x

So here is the story in short:

I was revising my C++ programming based on a book that I borrowed from a library titled, "Sams Teach Yourself C++ in One Hour a Day", written by Siddhartha Rao. The book is good. Its pact with tons of examples. But its proofreading is not so good. So, if your programming is not bad, you should be able to spot the mistakes when you read through. The downside to this book is that it does not mention the solution that we have to configure if certain examples does not work. for example, it makes quite a difference to,


#include <string> or its variant of .h</string>The extra blogger codes drives me crazy. I do not know about other books. To be honest, I never read other programming books in detail before. So, I don't know. But overall, I like the book.

Ok, I think I have drifted away. Let's get back on the track. So, today, while I am trying out the lambda function, I came across this error, "Lambda Expression Only Available With -std=c++0x or -std=gnu++0x".
I googled for quite sometime. Most of the answers are for those who are familiar with their IDE. They keep on saying add the command line to your compiler. I looked at my compiler setting, I scratched my head.

After searching and thinking for awhile. I opened up my compiler setting again for the second time. This time, I read carefully, then I saw something and I ticked it as shown below:

Binggo! That's it! It worked! Now, the codes can be compiled.

Hope that you enjoyed this post. It is not meant for those who are familiar with their IDEs. The last time I used codeblocks was in 2009. ;)