home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / hp / 13213 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.7 KB  |  69 lines

  1. 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
  2. From: mbheprg@hpa.ee.man.ac.uk (Raju Gurung)
  3. Newsgroups: comp.sys.hp
  4. Subject: linked pascal proc with C program
  5. Message-ID: <6814@m1.cs.man.ac.uk>
  6. Date: 20 Nov 92 14:52:18 GMT
  7. Sender: news@cs.man.ac.uk
  8. Organization: Electrical Engineering Dept Manchester University
  9. Lines: 58
  10.  
  11. Hi,
  12.     Hope someone can help with this little problem. I'm calling
  13. a pascal procedure from C program. Although the program runs ok,
  14. I'm having problems with arrays of double. Maybe I'm compiling and
  15. linking wrong. Anyway, the simplified program is:
  16.  
  17. ------ test.c ------
  18.  
  19. #include <stdio.h>
  20. #define SPT 5
  21.  
  22. extern void pas();
  23. typedef double glmma[SPT];
  24.  
  25. main()
  26. {
  27.   glmma a,b;
  28.   int   i,c;
  29.  
  30.   for(i=0;i<SPT;i++){
  31.     a[i]= i ;
  32.     b[i]= i ;
  33.   }
  34.  
  35.   c = 10;
  36.   pas(a,b,c);
  37.  
  38. }
  39. ------- testpas.p -----
  40.         
  41. $SUBPROGRAM$
  42.     program pas_main;
  43.         cont spt = 5    ;
  44.         type glmma = array [1..spt] of longreal    ;
  45.  
  46.     PROCEDURE pas(VAR m:glmma; VAR n: glmma; p: integer);
  47.     BEGIN
  48.         END;
  49.  
  50.     BEGIN
  51.     END.
  52. ----------------------
  53. I compiled and linked it by,
  54.  > pc -c -g testpas.p
  55.  > cc -o test -g test.c testpas.o -lc -lcl
  56.  
  57. When I checked with the debugger I found that m[0]=a[1],m[1]=a[1],m[2]=a[2]....
  58. Shouldn't it be m[1]=a[0], m[2]=a[1] ... ?
  59.    Trying to access m[0] in pas() would give me an error.
  60.  
  61. Any somebody help, or better still send me an example.
  62.  
  63. Cheers.
  64. -- 
  65. -----------------------------------------------------------------------
  66. | Raju Gurung, I.T. 109, I.T. Building, Dept. of Electrical Eng.,     | 
  67.   University of Manchester, Oxford Rd, Manchester, U.K.               |
  68. -----------------------------------------------------------------------
  69.