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?
Here is a link to gcc c++ 11 support. You also need to add -std=c++11 to your command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With