Opened 16 years ago

Last modified 16 years ago

#1022 closed defect (fixed)

External function with no input parameters do not typecheck!

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone:
Component: Version:
Keywords: Cc: Adrian Pop, Adrian Pop

Description

Bug pointed out by Alexander.Roehnsch <AT> dlr <DOT> de. Thanks!

I changed ExternalFunc1_ext() to take no arguments. Changed all the signatures and implementations. Like in the C file:
{{{double ExternalFunc1_ext()

{
return 2;
} }}}

And in the model:
{{{function ExternalFunc1

output Real y;

external y=ExternalFunc1_ext()

annotation(Library="libExternalFunc1_ext.o",

Include="#include\"ExternalFunc1_ext.h\"");

end ExternalFunc1;}}}

With a later call to:
der(x)=-ExternalFunc1();

Running the script gives off:
{{{>> runScript("ExternalLibraries.mos")

"
true

0

0

record

resultFile =
"Simulation failed.

No matching function found for ExternalFunc1() of type function() =>

Real,

candidates are function() => Real

Error occured while flattening model ExternalLibraries

"

end record
true"}}}

Change History (3)

comment:1 by barnet, 16 years ago

Dear Developers,

I wanted to report my finding that OpenModelica does not seem to be capable of handling a constructor for an external object that does not have an (input) argument.

Not sure if this is a bug or not.

Regards,

Beat Arnet

package ExtObj

class CGlobals

extends ExternalObject;

function constructor

output CGlobals cg;

external "C" cg=initCGlobals() ;
annotation(Include="#include \"../src/include.h\"",Library="ExtLib.lib");

end constructor;

function destructor

input CGlobals cg;

external "C" closeCGlobals(cg) ;
annotation(Include="#include \"../src/include.h\"",Library="ExtLib.lib");

end destructor;

end CGlobals;

model ExtObjtest

CGlobals cg=CGlobals();
Real y;

equation

y=testCGlobals(cg);

end ExtObjtest;

function testCGlobals

input CGlobals cg;
output Real y;

external "C" y=testCGlobals(cg) ;

end testCGlobals;

end ExtObj;

model testextobj

ExtObj.ExtObjtest t;

end testextobj;

record

resultFile = "Simulation failed.

No matching function found for CGlobals() of type function() => ExtObj.CGlobals ExternalObject, candidates are function() => ExtObj.CGlobals ExternalObject
Error occured while flattening model testextobj
"
end record

comment:2 by Adrian Pop, 16 years ago

Hi,

Have you tried the latest nightly-build?
http://www.ida.liu.se/~pelab/modelica/OpenModelica/OMC/nightly-builds/|http://www.ida.liu.se/~pelab/modelica/OpenModelica/OMC/nightly-builds/

There was an issue with I believe any function having no input parameters,
but I believe I fixed it in the latest nightly build. Give it a try and let me know
so I can reopen the bug if is still present for external objects.

Cheers,
Adrian Pop/

comment:3 by barnet, 16 years ago

Adrian,

The problem is indeed resolved.

Many thanks!

Beat

Note: See TracTickets for help on using tickets.