Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Structs vs. single parameters in C API #667
Some functions of the C API uses single parameters e.g.
fmi3Status fmi3SetupExperiment(fmi3Instance instance, fmi3Boolean toleranceDefined, fmi3Float64 tolerance, fmi3Float64 startTime, fmi3Boolean stopTimeDefined, fmi3Float64 stopTime);
others use structs e.g.
fmi3Status fmi3NewDiscreteStates(fmi3Instance instance, fmi3EventInfo* eventInfo);
and some use a combination of both e.g.
fmi3Instance fmi3Instantiate(fmi3String instanceName, fmi3InterfaceType fmuType, fmi3String fmuInstantiationToken, fmi3String fmuResourceLocation, const fmi3CallbackFunctions* functions, fmi3Boolean visible, fmi3Boolean loggingOn, const fmi3CoSimulationConfiguration* fmuCoSimulationConfiguration);
Both approaches have their advantages:
IMHO we should consider whether we really need structures as parameters and if so, come up with a rule when to use (and how to extend) them.
Regular Design meeting:
Pierre: I do not have a strong opinion. If I would be redoing it, I would try to avoid structs. Structs have the benefit, that one could add elements in the future.
--> Discuss at F2F meeting
The initial reason for structs was that we could simply extend without changing the function signature. This turned out to be a hollow reason - we never really used this to prevent API changes.
I would suggest to be consistent and remove all structures.