graal icon indicating copy to clipboard operation
graal copied to clipboard

Anonymous Union

Open webfolderio opened this issue 6 years ago • 1 comments

Is it possible to add annoymous union usage to CInterfaceTutorial.java

I am trying to bind libuv structures to C interface but couldn't find a proper way to do it.

Sample code snipplet:

typedef struct uv_stdio_container_s {
  uv_stdio_flags flags;

  union {
    uv_stream_t* stream;
    int fd;
  } data;
} uv_stdio_container_t;

webfolderio avatar Oct 19 '19 09:10 webfolderio

To bind native structures like uv_stdio_container_t from the libuv library to Java, you typically use Java Native Interface (JNI) or other Java Native Access (JNA) libraries. However, directly using anonymous unions in Java is not straightforward because Java does not have a native concept of unions.

medoussboug avatar Jan 25 '24 15:01 medoussboug