home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!doc.ic.ac.uk!uknet!mucs!hpa.ee.man.ac.uk!mbheprg
- From: mbheprg@hpa.ee.man.ac.uk (Raju Gurung)
- Newsgroups: comp.sys.hp
- Subject: linked pascal proc with C program
- Message-ID: <6814@m1.cs.man.ac.uk>
- Date: 20 Nov 92 14:52:18 GMT
- Sender: news@cs.man.ac.uk
- Organization: Electrical Engineering Dept Manchester University
- Lines: 58
-
- Hi,
- Hope someone can help with this little problem. I'm calling
- a pascal procedure from C program. Although the program runs ok,
- I'm having problems with arrays of double. Maybe I'm compiling and
- linking wrong. Anyway, the simplified program is:
-
- ------ test.c ------
-
- #include <stdio.h>
- #define SPT 5
-
- extern void pas();
- typedef double glmma[SPT];
-
- main()
- {
- glmma a,b;
- int i,c;
-
- for(i=0;i<SPT;i++){
- a[i]= i ;
- b[i]= i ;
- }
-
- c = 10;
- pas(a,b,c);
-
- }
- ------- testpas.p -----
-
- $SUBPROGRAM$
- program pas_main;
- cont spt = 5 ;
- type glmma = array [1..spt] of longreal ;
-
- PROCEDURE pas(VAR m:glmma; VAR n: glmma; p: integer);
- BEGIN
- END;
-
- BEGIN
- END.
- ----------------------
- I compiled and linked it by,
- > pc -c -g testpas.p
- > cc -o test -g test.c testpas.o -lc -lcl
-
- When I checked with the debugger I found that m[0]=a[1],m[1]=a[1],m[2]=a[2]....
- Shouldn't it be m[1]=a[0], m[2]=a[1] ... ?
- Trying to access m[0] in pas() would give me an error.
-
- Any somebody help, or better still send me an example.
-
- Cheers.
- --
- -----------------------------------------------------------------------
- | Raju Gurung, I.T. 109, I.T. Building, Dept. of Electrical Eng., |
- University of Manchester, Oxford Rd, Manchester, U.K. |
- -----------------------------------------------------------------------
-