totalspectrum / spin2cpp

Tool to convert Parallax Propeller Spin code to PASM, C++ or C
Other
46 stars 17 forks source link

C++: struct/class should be implicitly typedef'd #174

Open Wuerfel21 opened 3 years ago

Wuerfel21 commented 3 years ago

Should work, but doesn't:

struct SomeClass {
    int var;
};

int main() {
    SomeClass c = {123};
    _OUTA = c.var;
}
totalspectrum commented 3 years ago

I think this should be fixed now, thanks for bringing it up.

totalspectrum commented 3 years ago

Aargh, it's not as simple as just typedef'ing the names, because this can lead to conflicts with other names :(. Re-opening for now, but I suspect this will become a "will not fix" (we don't claim full C++ compliance for flexcc anyway).

Wuerfel21 commented 3 years ago

It is as simple as that, FlexC just doesn't handle type names conflicting with identifiers.

typedef int mytype;

int test(mytype mytype) {
    return (int) mytype;
}

Then again, using the same name for type and identifier is like, terrible programming practice and I have no idea why C allows this.