Skip to content
Prev 61532 / 63421 Next

Breaking Change in Rcomplex Layout?

Okay, but I'm afraid this will only mean something to Rust users. The
reason being that we encountered this issue in extendr: a Rust extension
library for R. The specific compiler errors we encounter happen because
bindgen (the Rust code generation library) read the changed R header files,
and generated a new type definition for Rcomplex. Then, our downstream code
that uses that bindgen-generated code caused rustc compiler errors such as:

error[E0560]: union `libR_sys::Rcomplex` has no field named `r`
  --> extendr-api\src\robj\into_robj.rs:93:20
   |
93 |         Rcomplex { r: 0., i: 0. }
   |                    ^ `libR_sys::Rcomplex` does not have this field
   |
   = note: available fields are: `__bindgen_anon_1`, `private_data_c`

and

error[E0609]: no field `i` on type `libR_sys::Rcomplex`
   --> extendr-api\src\scalar\rcplx_default.rs:105:35
    |
105 |         Rcplx(c64::new(val.r, val.i))
    |                                   ^ unknown field
    |
    = note: available fields are: `__bindgen_anon_1`, `private_data_c`
help: one of the expressions' fields has a field of the same name
    |
105 |         Rcplx(c64::new(val.r, val.__bindgen_anon_1.i))
    |                                   +++++++++++++++++

However, to put this into context, I would expect that C, C++ packages
would encounter a similar issue if they tried to access or modify specific
Rcomplex fields in the same way.

On Mon, Apr 3, 2023 at 11:39?PM Tomas Kalibera <tomas.kalibera at gmail.com>
wrote: