c++c++11codeblocks

why can't I use clock_t in codeblocks 12.11 compiler?


I am trying to compile a code in codeblocks but it is showing some error.
my code was:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<iostream>
using namespace std;
void f()
{
   int sum=0;
   for(int i=0;i<100000000;i++)
       sum++;
}
int main()
{
   clock_t start,end;
   start=clock();
   f();
   end=clock();
   cout<<((double)end-start)/CLOCKS_PER_SEC<<endl;
}  

but it is showing some error, the error is like that:
" #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options."
what will I do now?


Solution

  • As suggested by the error, simply enable the C++11 feature. To do so (thanks to @chris' comment) :

    It's right in the settings. There's like literally an option that says "Use the C++11 standard".