Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

resolving anonymous struct in C library

20 views
Skip to first unread message

W G

unread,
Jun 14, 2021, 11:04:34 AM6/14/21
to javacpp

Hi there,

I am trying to build a javacpp-preset for the Leap Motion controller in Windows. I am getting a compiler issue for the following snippet of code found in the LeapC.h header file (attached).

Snippet from C Header file:
```
typedef struct _LEAP_DISTORTION_MATRIX {
  /** A point in the distortion grid. @since 3.0.0 */
  struct {
    /** The x-pixel coordinate. @since 3.0.0 */
    float x;
    /** The y-pixel coordinate. @since 3.0.0 */
    float y;
  }
  /** A grid of 2D points. @since 3.0.0 */
  matrix[LEAP_DISTORTION_MATRIX_N][LEAP_DISTORTION_MATRIX_N];
LEAP_DISTORTION_MATRIX;
```

The compiler error:
distortion matrix.png

this is the current state of the presets/leapmotion.java file:
```
package org.bytedeco.leapmotion.presets;

import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
import org.bytedeco.javacpp.tools.*;

@Properties(
    value = {
        @Platform(
                value = "windows",
                include = "LeapC.h",
                link = "LeapC")
    },
    target = "org.bytedeco.leapmotion",
    global = "org.bytedeco.leapmotion.global.leapmotion"
)
public class leapmotion implements InfoMapper {
    static { Loader.checkVersion("org.bytedeco""leapmotion"); }

    public void map(InfoMap infoMap) {

        infoMap.put(new Info("LEAP_EXPORT","LEAP_CALL","LEAP_STATIC_ASSERT","static_assert").cppTypes().annotations())
                
                .put(new Info("_LEAP_CONNECTION").pointerTypes("LEAP_CONNECTION"))
                .put(new Info("LEAP_CONNECTION").valueTypes("LEAP_CONNECTION").pointerTypes("@Cast(\"LEAP_CONNECTION*\") _LEAP_CONNECTION""@ByPtrPtr LEAP_CONNECTION"))
                
                .put(new Info("_LEAP_DEVICE").pointerTypes("LEAP_DEVICE"))
                .put(new Info("LEAP_DEVICE").valueTypes("LEAP_DEVICE").pointerTypes("@Cast(\"LEAP_DEVICE*\") _LEAP_DEVICE""@ByPtrPtr LEAP_DEVICE"))

                .put(new Info("_LEAP_CLOCK_REBASER").pointerTypes("LEAP_CLOCK_REBASER"))
                .put(new Info("LEAP_CLOCK_REBASER").valueTypes("LEAP_CLOCK_REBASER").pointerTypes("@Cast(\"LEAP_CLOCK_REBASER*\") _LEAP_CLOCK_REBASER""@ByPtrPtr LEAP_CLOCK_REBASER"))

                .put(new Info("_LEAP_RECORDING").pointerTypes("LEAP_RECORDING"))
                .put(new Info("LEAP_RECORDING").valueTypes("LEAP_RECORDING").pointerTypes("@Cast(\"LEAP_RECORDING*\") _LEAP_RECORDING""@ByPtrPtr LEAP_RECORDING"))

                .put(new Info("_LEAP_CALIBRATION").pointerTypes("LEAP_CALIBRATION"))
                .put(new Info("LEAP_CALIBRATION").valueTypes("LEAP_CALIBRATION").pointerTypes("@Cast(\"LEAP_CALIBRATION*\") _LEAP_CALIBRATION""@ByPtrPtr LEAP_CALIBRATION"));
         
    }
}
```

How do I handle this struct that has a nested struct in it? (I believe it is an anonymous struct too)

Thanks!
LeapC.h

Samuel Audet

unread,
Jun 14, 2021, 11:31:08 AM6/14/21
to javacpp...@googlegroups.com, W G
On 6/14/21 11:59 PM, W G wrote:
> How do I handle this struct that has a nested struct in it? (I believe it is an anonymous struct too)

Anonymous structs are supported. This should work pretty much as is.
Could you please open an issue about that on GitHub?
https://github.com/bytedeco/javacpp/issues
Reply all
Reply to author
Forward
0 new messages