Skip to content

Anonymous union types in structs lead to invalid generated code #190

Open
@david-bouyssie

Description

@david-bouyssie

In this header file
https://github.com/mzdb/rmzdb/blob/master/src/libmzdb.h

I have a struct defining an inner anonymous union like this:

typedef struct libmzdb_spectrum_data
{
    libmzdb_data_encoding_t data_encoding;
    int peak_count;
    union {
        double* mz_array_as_doubles;
        float* mz_array_as_floats;
    };
    union {
        double* intensity_array_as_doubles;
        float* intensity_array_as_floats;
    };
    float* lwhm_array; // warning: can be NULL
    float* rwhm_array; // warning: can be NULL
} libmzdb_spectrum_data_t;

In the generated bindings some parts of the code are missing (see ERROR comments):

object struct_libmzdb_spectrum_data {
    import implicits._
    def apply()(implicit z: native.Zone): native.Ptr[struct_libmzdb_spectrum_data] = native.alloc[struct_libmzdb_spectrum_data]
    def apply(
      data_encoding: native.Ptr[libmzdb_data_encoding_t],
      peak_count: native.CInt,
       : native.Ptr[union_anonymous_1], // ERROR: argument name missing
       : native.Ptr[union_anonymous_2],  // ERROR: argument name missing
      lwhm_array: native.Ptr[native.CFloat],
      rwhm_array: native.Ptr[native.CFloat]
)(implicit z: native.Zone): native.Ptr[struct_libmzdb_spectrum_data] = {
      val ptr = native.alloc[struct_libmzdb_spectrum_data]
      ptr.data_encoding = data_encoding
      ptr.peak_count = peak_count
      ptr. =  // ERROR
      ptr. =  // ERROR
      ptr.lwhm_array = lwhm_array
      ptr.rwhm_array = rwhm_array
      ptr
    }
  }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions