- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Link to external "C" function with...
Link to external "C" function with variable arguments
Link to external "C" function with variable arguments
I am trying to call an external "C" function which has variable arguments from OpenModelica, however, the model code generated creates a prototype of the external function based on the actual type annd number of arguments passed to it. Is there anyway to get around this?
I essentially want to call functions in a python script from OpenModelica. Since this is not possible (to the best of my knowledge), I am trying to create a generic C++ interface between OpenModelica and Python (since python can be embedded in C++). The issue is for the interface to be generic, I must be able to accept any type and number of arguments from OpenModelica and accordingly pass them to a specified python script function.
Thanks in advance
-Prasant
Re: Link to external "C" function with variable arguments
There is no way to have a varargs-style function in Modelica. And there may be problems calling C++ functions as well (external C is pure C; no overloaded functions).
- sjoelund.se
- 1700 Posts
Re: Link to external "C" function with variable arguments
In Java, varargs is an array of objects. I'm 100% sure our external Java interface does not handle that; the signatures will be wrong.
I have one little suggestion regarding a generic interface though: Passing strings. It's slow, but should work.
PythonInterface.callReal("myPythonFunction(" + PythonInterface.realArrayToString(arg1) + ")")
You need to create one "call" function for every return type you want to have anyway, but you can have varargs.
- sjoelund.se
- 1700 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Link to external "C" function with...