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

c++, c++11, gcc

Solution

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

Problem

I am writing C++ app which should be compiled both using MS C++ on Windows and GCC on Linux.I wrote a loop on Windows which iterates through std::list: ``` auto iter = container.GetObj()->begin(); while (iter!=container.GetObj()->end()){ (*(iter++))->Execute(); } ``` It works fine ,but when compiling it with GCC "auto" gets not recognized: Unexptected token "auto" (in NetBeans IDE) So I fixed it defining the 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 it mean that GCC doesn't support auto keyword ?May be I need to upgrade the compiler?

Original source