简体   繁体   中英

Using modelica function as input to external "C" function

I am trying to call an external C function in modelica with a function as an argument. So the C function needs to take a modelica "function" as input. Is it possible to do that in modelica?

For example:

function foo

  input Function fun;
  output Real bar ;

  external "C" bar = myCFunction(fun) annotations(...);

end foo;

function Function
  input Real u;
  output Real y;
algorithm
   y := u*2;
end Function;

When I use the "check" option, I get some error stating fun is undeclared which I don't if I do not use a function as input. I looked online and in the use manual of dymola but I haven't found an example stating it was possible, nor impossible.

No, I don't think that's possible. You can check the Modelica Specification about allowed input types to external functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM