-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling LF as a library function. #2354
Comments
This seems doable. In the C target, the generated
Presumably, if this |
A solution could be prefixing both the library call and all global variables with the main LF file name. In that way each LF model will be uniquely defined. |
This is already how the C++, Rust and Typescript targets are designed. The runtime is implemented as a standalone library (i.e. it could be used in plain C++/Rust/Typescript code) and the LF code generator implements a layer on top that allows you to more conveniently define reactors. The LF code generator also produces a main function. However, you could simply write your own. All it takes to start a C++ reactor program is to instantiate the There are a couple of improvements that could be made to make this easier. In particular, I think it would be nice to make the individual LF files independent Cmake targets. This would allow you to more conveniently import and link against a specific reactor. |
A nontrivial application may consist of a complex of sub-LF applications each of which is called upon according to some underlying app logic (e.g. various simulators for different purposes). In order to enable such configuration it would be handy if each LF reactor model could be called as a library function, e.g.
int main_{i}(...)
instead of the defaultint main(...)
, and then linked against the (C/C++) glue code. Is that an option?The text was updated successfully, but these errors were encountered: