MSVC2012 release w/o error, MSVC2010 with errors

  • Hello, I am trying to release one app with both - VS2010 and VS2012 compiler... App release and debug fine with VS2012, but with VS2010 it debugs fine but not also release... When trying to release it I get following errors

    error: C2143: syntax error : missing ',' before ':'
    error: C2530: 'f' : references must be initialized
    error: C2143: syntax error : missing ';' before '{'

    @void MainWindow::on_Playlist_clicked()
    QString directory = QFileDialog::getExistingDirectory(this,tr("Select directory for files to import"),"C:/Users/x/Desktop/Filei");
    QDir dir(directory);
    QStringList files = dir.entryList(QStringList() << "*.mp3",QDir::Files);
    QList<QMediaContent> content;
    for(const QString& f:files)
    content.push_back(QUrl::fromLocalFile(dir.path()+"/" + f));
    QFileInfo fi(f);
    ui->listWidget1->setCurrentRow(playlist->currentIndex() != -1? playlist->currentIndex():0);


    I don't really understand why same application compile with VS2012 fine but not also with VS2010.. Its same source code, I tried qmake, cleaned project,.... nothing helped so far...

  • Moderators


    [quote author="Anonymous" date="1381575602"]
    for(const QString& f:files)
    [/quote]Range-based for loops are a new feature of C++11, which was released in 2011. VS 2010 doesn't support it properly.

    Rewrite it using a traditional loop and the error should go away.

  • Okay, thanks...

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.