csdms / bmi-c

Basic Model Interface for C
https://bmi.readthedocs.io
MIT License
1 stars 3 forks source link

Update bmi.h to pass pointer to struct Bmi #5

Closed mcflugen closed 4 years ago

mcflugen commented 4 years ago

This pull request updates bmi.h to pass pointers to a Bmi struct as a first argument.

int (*initialize)(struct Bmi *self, const char *config_file);

That is, the first argument is a struct Bmi *self rather than void *self.

Bmi * model = (Bmi*)malloc(sizeof(Bmi)); // Allocate memory for the BMI

register_bmi(model);  // Initialize the BMI methods and any model data

// Call the BMI methods
model->initialize(model, "config_file.txt");
model->update_until(model, 10.5);
model->finalize(model);

I've also wrapped the header with extern "C" for C++.