home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / ada / 2454 < prev    next >
Encoding:
Text File  |  1992-08-26  |  6.6 KB  |  202 lines

  1. Path: sparky!uunet!munnari.oz.au!goanna!minyos.xx.rmit.oz.au!stan!ng
  2. From: ng@saturn.cs.swin.oz.au (Naasif Gierdien)
  3. Newsgroups: comp.lang.ada
  4. Subject: Alsys compiler question
  5. Keywords: Alsys HP
  6. Message-ID: <6903@stan.xx.swin.oz.au>
  7. Date: 26 Aug 92 10:03:35 GMT
  8. Sender: news@stan.xx.swin.oz.au
  9. Followup-To: comp.lang.ada
  10. Organization: Swinburne University of Technology, Hawthorn, Victoria, Australia.
  11. Lines: 189
  12.  
  13. Heres my problem. We are running the Alsys compiler on Hp9000's
  14. and are trying to implement Ada-C-Ada calls.
  15.  
  16. Heres the example out of the Reference Manual. I used the
  17. default family (public) and created a new library.
  18.  
  19. Being rather a beginner to Alsys I'm not quite sure what I'm doing
  20. wrong.After typing 'compile callback.ada' I get the errors below.
  21.  
  22. Can anyone help.. ??
  23.  
  24. ---cut here---
  25.  
  26. Alsys Ada version 5.5.0
  27.  
  28. Example taken from page 1-10 in the Appendix F manual for
  29. Alsys Ada Software Development Environment for HP 9000 series
  30. 300 and 400.
  31. Second Edition May 1992.
  32.  
  33. ---------------------------------------------------------------
  34. FILE : callback.c
  35. --------------- CUT HERE --------------------------------------
  36. extern void hi_there ();
  37.  
  38. /* procedure GO_TO_C gets called from Ada MAIN, adds 5 to
  39.    argument, and calls Ada routine HI_THERE */
  40.  
  41. void go_to_c (c_arg)
  42.     int c_arg;
  43. {
  44.    hi_there (c_arg + 5);
  45. }
  46. --------------- CUT HERE --------------------------------------
  47.  
  48. ---------------------------------------------------------------
  49. FILE : callback.ada
  50. --------------- CUT HERE --------------------------------------
  51.  
  52. with TEXT_IO;
  53.  
  54. package FROM_C is
  55.  
  56.     -- Declaration of Ada routine HI_THERE, to be called
  57.     -- from C. This must be in a library package.
  58.  
  59.     procedure HI_THERE (ADA_ARG : in INTEGER);
  60.  
  61.     pragma EXPORT (C, HI_THERE);
  62.  
  63. end FROM_C;
  64.  
  65. package body FROM_C is
  66.  
  67.     procedure HI_THERE (ADA_ARG : in INTEGER) is
  68.         -- This procedure called from C. It will write a
  69.         -- message including the value passed into ADA_ARG.
  70.    begin
  71.         TEXT_IO.PUT_LINE ("Now in Ada, call from C!");
  72.         TEXT_IO.PUT_LINE
  73.               ("integer passed was" & INTEGER'IMAGE (ADA_ARG));
  74.    end HI_THERE;
  75.  
  76. end FROM_C;
  77.  
  78. with FROM_C; -- **** WITH IS NECESSARY SO FROM_C GETS
  79.                  -- **** INCLUDED IN PROGRAM
  80. procedure MAIN is
  81.  
  82.     -- This is an Ada main procedure. it will call a C routine
  83.     -- called GO_TO_C, passing the value 5 to that routine.
  84.  
  85.     -- GO_TO_C will call the Ada routine HI_THERE to demonstrate
  86.     -- callbacks.
  87.  
  88.     -- The C routine that will call Ada:
  89.  
  90.     procedure GO_TO_C (C_ARG : in INTEGER);
  91.     pragma INTERFACE (C, GO_TO_C);
  92.  
  93. begin
  94.  
  95.     -- Call C. C will the call Ada.
  96.     GO_TO_C (5);
  97.  
  98. end MAIN;
  99. ---------------------------------------------------------------
  100. COMPILER OUTPUT
  101. --------------- CUT HERE --------------------------------------
  102.  
  103. ---- HP9000s300 HP-UX Alsys Ada compiler V5.5 --------------------------------------------------------------------------------------
  104.  
  105. Source File : /se16/drb/SQ503/AdaC/callback.ada
  106. Ada Library : /se16/drb/SQ503/AdaC/adac
  107. Compiled on : 1992-08-26 19:36:08
  108. Options     : SOURCE="callback.ada",LIBRARY="adac",ERRORS=50,LEVEL=UPDATE,CHECKS=ALL,GENERICS=INLINE,MEMORY=500,OUTPUT="callback.
  109.               out",WARNING=YES,TEXT=YES,SHOW=ALL,DETAIL=YES,ASSEMBLY=NONE,INLINE=PRAGMA,REDUCTION=NONE,EXPRESSIONS=NONE,OBJECT=
  110.               PEEPHOLE,TREE=NO,DEBUG=NO,COPY=NO,EDIT=NONE
  111.  
  112.                                                                                                       Next message at line:      10
  113. ------------------------------------------------------------------------------------------------------------------------------------
  114.  
  115.  
  116.         1 with TEXT_IO;
  117.         2 
  118.         3 package FROM_C is
  119.         4 
  120.         5         -- Declaration of Ada routine HI_THERE, to be called
  121.         6         -- from C. This must be in a library package.
  122.         7 
  123.         8         procedure HI_THERE (ADA_ARG : in INTEGER);
  124.         9 
  125.        10         pragma EXPORT (C, HI_THERE);
  126.                                     <--1--->  
  127.  1    *IDE The implementation defined pragma EXPORT is only allowed for an object declared by an object declaration. This pragma 
  128.            has been ignored. - RM Appendix F.
  129.  
  130.        11 
  131.        12 end FROM_C;
  132.        13 
  133.        14 package body FROM_C is
  134.        15 
  135.        16         procedure HI_THERE (ADA_ARG : in INTEGER) is
  136.        17                 -- This procedure called from C. It will write a
  137.        18                 -- message including the value passed into ADA_ARG.
  138.        19    begin
  139.        20                 TEXT_IO.PUT_LINE ("Now in Ada, call from C!");
  140.        21                 TEXT_IO.PUT_LINE
  141.        22                           ("integer passed was" & INTEGER'IMAGE (ADA_ARG));
  142.        23    end HI_THERE;
  143.        24 
  144.        25 end FROM_C;
  145.        26 
  146.        27 with FROM_C; -- **** WITH IS NECESSARY SO FROM_C GETS
  147.        28                                  -- **** INCLUDED IN PROGRAM
  148.        29 procedure MAIN is
  149.        30 
  150.        31         -- This is an Ada main procedure. it will call a C routine
  151.        32         -- called GO_TO_C, passing the value 5 to that routine.
  152.        33 
  153.        34         -- GO_TO_C will call the Ada routine HI_THERE to demonstrate
  154.        35         -- callbacks.
  155.        36 
  156.        37         -- The C routine that will call Ada:
  157.        38 
  158.        39         procedure GO_TO_C (C_ARG : in INTEGER);
  159.        40         pragma INTERFACE (C, GO_TO_C);
  160.        41 
  161.        42 begin
  162.        43 
  163.        44         -- Call C. C will the call Ada.
  164.        45         GO_TO_C (5);
  165.        46 
  166.        47 end MAIN;
  167.        48 
  168. ---- HP9000s300 HP-UX Alsys Ada compiler V5.5 --------------------------------------------------------------------------------------
  169. /se16/drb/SQ503/AdaC/callback.ada
  170. ------------------------------------------------------------------------------------------------------------------------------------
  171.  
  172.  
  173.  
  174.   Number of diagnostics  Possible results  Severity level 
  175.  
  176.        1   warning       object code          (*)
  177.  
  178.        0   error         no object code       (**)
  179.  
  180.        0   error         analysis stopped     (***)
  181.  
  182.        0   fatal error   immediate abort      (****)
  183.  
  184.  
  185.  
  186.  No errors detected.  One warning issued. Compilation completed.
  187.  ---------------------------------------------------------------
  188.  
  189.  
  190. Faulty line is: 
  191. ------------------------------------------------------------------------------------------------------------------------------------
  192.  
  193.     *:10            
  194. ------------------------------------------------------------------------------------------------------------------------------------
  195.  
  196. --------------- CUT HERE --------------------------------------
  197.  
  198. -- 
  199. Naasif Gierdien
  200. ng@saturn.cs.swin.oz.au
  201. Swinburne University of Technology, Hawthorn, Victoria, Australia.
  202.