Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Wuerfel21 opened this issue Jun 20, 2021 · 3 comments
Open

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

Wuerfel21 opened this issue Jun 20, 2021 · 3 comments

Comments

@Wuerfel21
Copy link
Contributor

Should work, but doesn't:

struct SomeClass {
    int var;
};

int main() {
    SomeClass c = {123};
    _OUTA = c.var;
}
@totalspectrum
Copy link
Owner

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

@totalspectrum
Copy link
Owner

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).

@totalspectrum totalspectrum reopened this Jun 28, 2021
@Wuerfel21
Copy link
Contributor Author

Wuerfel21 commented Jun 28, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants