Using "auto" keyword for std :: list iterator with GCC

I am writing a C ++ application that needs to be compiled using both MS C ++ on Windows and GCC on Linux. I wrote a loop on Windows that iterates through std :: list:

 auto  iter = container.GetObj()->begin();
 while (iter!=container.GetObj()->end()){

   (*(iter++))->Execute();

 }

      

It works fine, but when compiled with GCC, "auto" is not recognized:

Auto token inactive (in NetBeans IDE)

So I fixed it by defining an iterator "explicitly:

 std::list<Container*>::iterator iter=container.GetObj()->begin();
 while (iter!=container.GetObj()->end()){

   (*(iter++))->Execute();

 }

      

My GCC version is 4.7.2

Does this mean that GCC does not support the auto keyword? Maybe I need to update the compiler?

+3


source to share


1 answer


Here is a link to gcc C ++ 11 support. You also need to add -std = C ++ 11 to your command line.



+6


source







All Articles