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

JNAerator: Anonymous nested unions/structs are converted to nested classes with same name as enclosing class #132

Open
mvarnim opened this issue May 24, 2022 · 0 comments

Comments

@mvarnim
Copy link

mvarnim commented May 24, 2022

Issue description

A c union containing anonymous unions and structs is defined in a header file:

typedef union myUnion{
    double data[4];
    struct{
        union{
            struct{
                double vec[3];
                
            };
            struct{
                double i;
                double j;
                double k;
            };
        };
        double s;
    };
} myUnion;

This is converted to Java classes by JNAerator in the form:

public class myUnion extends Union {
	public double[] data = new double[4];
	public field1_struct field1;
	public static class field1_struct extends Structure {
		public field1_union field1;
		public double s;
		public static class field1_union extends Union {
			public field1_struct field1;
			public field2_struct field2;
			public static class field1_struct extends Structure {
				/** C type : double[3] */...

The inner class field1_struct, which represents the inner anonymous struct, has the same name as the enclosing class, which represents the outer anonymous struct. JNAerator generates these names automatically in the absence of struct names in the native code.

This leads to the Java error The nested type field1_struct cannot hide an enclosing type.

An interim solution is manual modification of the generated Java files after running JNAerator.

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

1 participant