I'm trying to get JNAerator to generate some JNA backed Java code from a C shared library and everything is fine except that it failed to generate an unnamed union nested inside a structure.
Example:
typedef struct MY_STRUCTURE {
union {
My_Type1 var1;
My_Type2 var2;
};
}MY_STRUCTURE;
If I change the header to make the union have a name it will work. But for obvious reasons I can't just change the header without breaking the shared library I'm trying to use.
Any solutions other than changing the header file and shared library to named union?
Adding a name won't change the memory layout, so you can change the name, JNAerate the Java code (which will map the memory/structure appropriately) and then undo your change. JNA's mapping of the structure to your actual library won't be impacted by adding a name.
edit: your results are a little strange, since the JNAerator documentation clearly addresses the anonymous types problem and seems to indicate that it should produce the correct results.