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

Struct definition with the word struct in it generates invalid C# code #173

Closed
mjsabby opened this issue Sep 15, 2020 · 2 comments · Fixed by #256
Closed

Struct definition with the word struct in it generates invalid C# code #173

mjsabby opened this issue Sep 15, 2020 · 2 comments · Fixed by #256

Comments

@mjsabby
Copy link
Contributor

mjsabby commented Sep 15, 2020

struct a {
	struct a *next;
	struct a *prev;
};

produces

    public unsafe partial struct a
    {
        [NativeTypeName("struct a*")]
        public struct a* next;

        [NativeTypeName("struct a*")]
        public struct a* prev;
    }
@mjsabby
Copy link
Contributor Author

mjsabby commented Sep 15, 2020

@tannergooding any suggestions on this one?

@tannergooding
Copy link
Member

This looks to be specific to processing in C mode. It works as expected for C++ mode.

It looks like in both cases it is a Pointer where the PointeeType is an ElaboratedType and the NamedType is then a TagType.
However, for C++ the TagType has a name of a while in C it is struct a and so there would need to be a check that strips the struct or enum prefix from it in this case: https://github.com/microsoft/ClangSharp/blob/master/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs#L1305

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

Successfully merging a pull request may close this issue.

2 participants