I have an existing C++ and Qt program that builds fine under MSVC but fails to build with MinGW.
Under MinGW I get lots of syntax errors such as:
Redefinition of 'QString foobar'
I have extracted the issue into a minimum working example:
//main.cpp
#include <QString>
#include <iostream>
using namespace std;
class MyClass {
public:
    MyClass(const QString &foo, const QString &bar, const QString baz)
        : foo_(foo), bar_(bar), baz_(baz) {}
    QString foo_;
    QString bar_;
    QString baz_;
};
int main(int argc, char **argv) {
    QString foo = QString("foo");
    QString bar = QString("bar");
    QString baz = QString("baz");
    MyClass my(foo, bar, baz);
    QString a = QString(foo);
    QString b = QString(bar);
    QString c = QString(baz);
    MyClass my2(a,b,c);
    MyClass my3(QString(foo), QString(bar), QString(baz));
    //MyClass my4(QString(foo), QString(bar), QString(foo)); //redefinition error
    return 0;
}
Which gives the error:
main.cpp:31: error: C2086: 'QString foo' : redefinition
As pointed out in the comments my problem is being caused by a parse issue that is called "most vexing parse". With this knowledge I have refined my issue further and found the following difference between MSVC and MinGW. The following line of code compile under MSVC2013 but not under MinGW:
MyClass my5(QString(foo), QString(bar), QString(foo), Foo::Foobar(5));
It seems that adding "Foo::Foobar(5)" causes MSVC to see this line as a variable declaration, but MinGW still sees this as function declaration.
My question is, can I work around this issue through some compile flag in GCC, or must I refactor my whole project to avoid the most vexing parse issue all together.