rust-GSL
rust-GSL copied to clipboard
Incorrect ffi-binding to gsl_multifit_function_fdf
GSL header gsl_multifit_nlin.h
specifies gsl_multifit_function_fdf
as
struct gsl_multifit_function_fdf_struct
{
int (* f) (const gsl_vector * x, void * params, gsl_vector * f);
int (* df) (const gsl_vector * x, void * params, gsl_matrix * df);
int (* fdf) (const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix *df);
size_t n; /* number of functions */
size_t p; /* number of independent variables */
void * params; /* user parameters */
size_t nevalf; /* number of function evaluations */
size_t nevaldf; /* number of Jacobian evaluations */
};
typedef struct gsl_multifit_function_fdf_struct gsl_multifit_function_fdf ;
but Rust ffi binding misses last two fields: https://github.com/GuillaumeGomez/rust-GSL/blob/b06c6732fd1155825141b28844f764cb396907dc/src/ffi/solvers.rs#L150-L168
I noticed this when saw undefined behaviour of my Rust code: some of my variables are changed by MultiFitFSolver::set()
, but I didn't passed them there. Probably it also can cause problems described by #67
I'm currently writing the script to check that the Rust bindings are correct. I realized that a few types/functions had mismatching definitions compared to the C one.
Can the ffi bindings be generated by bindgen
?
Yes but I don't like the generated code.
This issue was fixed when we (finally) switched to automated FFI code generation.