Opened 18 years ago
Last modified 18 years ago
#78 closed defect (fixed)
Called function behind caller function in cpp file
Reported by: | Robert.Wotzlaw | Owned by: | Robert.Wotzlaw |
---|---|---|---|
Priority: | critical | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | Robert.Wotzlaw, Adrian Pop |
Description
Change History (4)
comment:1 by , 18 years ago
comment:3 by , 18 years ago
(In reply to comment #1)
This bug might be fixed, which version did you use?
/Peter
I used the OpenModelica 1.4.1 Source Release for people with SVN problems.
It is perhaps SVN Vers. 2431.
regards
Robert Wotzlaw
Note:
See TracTickets
for help on using tickets.
Dear Mr. Peter Aronsson,
something new. Bug in cpp source file, a function called a function that is
behind the caller function.
The platform and compiler
Debian Sarge Linux Knoppix Quantian with GNU GCC 3.3 and OpenModelica 1.4.1
The BugDebCoefficient.mo OpenModelica source code file:
class BugDebCoefficient
equation
end BugDebCoefficient;
In the OMShell
true
"fclass BugDebCoefficient
Real L;
Real Psi;
Real U;
Real i;
equation
end BugDebCoefficient;
"
record
"
end record
The error.log file
01:BugDebCoefficient.cpp: In function `int functionDAE_output()':
02:BugDebCoefficient.cpp:441: error: `residualFunc2' undeclared (first use this
03: function)
04:BugDebCoefficient.cpp:441: error: (Each undeclared identifier is reported only
05: once for each function it appears in.)
06:BugDebCoefficient.cpp: In function `void residualFunc2(int *, double*,
double*, int*)
07:':
08:BugDebCoefficient.cpp:459: error: `void residualFunc2(int *, double*,
double*, int*)'
09: used prior to declaration
10:make: * [BugDebCoefficient] Error 1
BugDebCoefficient.cpp file generated from omc (excerpts)
432:int functionDAE_output()
433:{
434: state mem_state;
437: mem_state = get_memory_state();
438: start_nonlinear_system(2);
439: nls_x[1] = $i;
400: nls_x[0] = $L;
441: hybrd_(residualFunc2,&n, nls_x, nls_fvec,&xtol,&maxfev,&ml,&mu,&epsfcn,
442: nls_diag,&mode,&factor,&nprint,&info,&nfer,nls_fjac,&ldfjac,
443: nls_r,&lx,nls_qtf,nls_wa1,nls_wa2,nls_wa3,nls_wa4);
457:}
458:void void residualFunc2(int *n, double* xloc, double* res, int* flag)
459:{
460: modelica_boolean tmp0;
472:}
The workaround
I moved the function residualFunc() in front of the function functionDAE_output().
432:void void residualFunc2(int *n, double* xloc, double* res, int* flag)
433:{
434: modelica_boolean tmp0;
446:}
448:int functionDAE_output()
449:{
450: state mem_state;
473:}
Now I run the makefile BugDepCoefficient.makefile:
$: make -f BugDepCoefficient.makefile 2>&1 | tee make_all.log
The source file BugDepCoefficient.cpp was compiled without an error.
In the next step I run the BugDepCoefficient.exe file:
$: ./BugDepCoefficient.exe
The output is the BugDepCoefficient_res.plt file. I ploted the numbers with my
runptplot shell script:
$: ./runptplot BugDepCoefficient_res.plt
The result I saw, was corret. The equation Psi = L*i is linear time depend with
a slope of one. So differential equation U = der(Psi) is valid.
For informational purpose only, the source of the runptplot script:
01:#!/bin/sh
02:echo Running 'java ptolemy.plot $*' with /home/knoppix/DebianPackageBuild/
omc/omc-1.4.1-resource/ptplot.jar appended to the CLASSPATH variable
03:export CLASSPATH
04:export CLASSPATH=$CLASSPATH:/home/knoppix/DebianPackageBuild/omc/
omc-1.4.1-resource/ptplot.jar
05:/usr/lib/j2se/1.4/jre/bin/java ptolemy.plot.plotml.EditablePlotMLApplication $*
regards
Robert Wotzlaw