Qt Code:
#include <QList> int main(int , char ** ) { struct Foo { int bar; }; QList<Foo> foo; return 0; }To copy to clipboard, switch view to plain text mode
This short program fails to compile for me (using gcc-4.1.0):
prog.cc: In function 'int main(int, char**)':
prog.cc:9: error: 'main(int, char**)::Foo' uses local type 'main(int, char**)::Foo'
prog.cc:9: error: trying to instantiate 'template<class T> class QList'
prog.cc:9: error: invalid type in declaration before ';' token
I can get it to compile by declaring the struct outside the method were it will be used, but since I only need it on one method it feels natural to declare it there.
Not sure if this is a Qt problem or a gcc problem. Is there anyone who knows why you can't make a list of a locally declared struct?
Bookmarks