Open Timmmm opened 5 months ago
Sorry I didn't reply earlier. Yes I think this would be fine.
I do have a local branch that wraps the C code generator in a parameterised module, which makes it much easier to make the behavior configurable. Maybe I should push that first?
Ah yeah that definitely makes sense. No rush though; our hacks are working for now.
As described here, if you are using C++ you can get multiple instances of a model without having to add an explicit
context
parameter everywhere (I believe there was an attempted "C2" backend that tried this at some point). Currently I have to do a few hacks to make it work but it would be nice to have an official mode that supported this.This requires a flag that changes the C output slightly:
#includes
at all.#ifndef __cplusplus
. I don't think that is actually necessary at all.static
.void (*sail_rts_set_coverage_file)(const char *) = &sail_set_coverage_file;
.This allows creating independent model instances by wrapping the code in a struct or class like this:
Where
ModelRuntime
is a class that provides all of the C functions that the model expects.I think those would be fairly minimal changes to the compiler? Would it be ok if I added this feature?