From: ng@saturn.cs.swin.oz.au (Naasif Gierdien)
Newsgroups: comp.lang.ada
Subject: Alsys compiler question
Keywords: Alsys HP
Date: 26 Aug 92 10:03:35 GMT
Followup-To: comp.lang.ada
Organization: Swinburne University of Technology, Hawthorn, Victoria, Australia.

Heres my problem. We are running the Alsys compiler on Hp9000's
and are trying to implement Ada-C-Ada calls.

Heres the example out of the Reference Manual. I used the
default family (public) and created a new library.

Being rather a beginner to Alsys I'm not quite sure what I'm doing
wrong.After typing 'compile callback.ada' I get the errors below.

Can anyone help.. ??

---cut here---

Alsys Ada version 5.5.0

Example taken from page 1-10 in the Appendix F manual for
Alsys Ada Software Development Environment for HP 9000 series
300 and 400.
Second Edition May 1992.

---------------------------------------------------------------
FILE : callback.c
--------------- CUT HERE --------------------------------------
extern void hi_there ();

/* procedure GO_TO_C gets called from Ada MAIN, adds 5 to
   argument, and calls Ada routine HI_THERE */

void go_to_c (c_arg)
    int c_arg;
{
   hi_there (c_arg + 5);
}
--------------- CUT HERE --------------------------------------

---------------------------------------------------------------
FILE : callback.ada
--------------- CUT HERE --------------------------------------

with TEXT_IO;

package FROM_C is

	-- Declaration of Ada routine HI_THERE, to be called
	-- from C. This must be in a library package.

	procedure HI_THERE (ADA_ARG : in INTEGER);

	pragma EXPORT (C, HI_THERE);

end FROM_C;

package body FROM_C is

	procedure HI_THERE (ADA_ARG : in INTEGER) is
		-- This procedure called from C. It will write a
		-- message including the value passed into ADA_ARG.
   begin
		TEXT_IO.PUT_LINE ("Now in Ada, call from C!");
		TEXT_IO.PUT_LINE
			  ("integer passed was" & INTEGER'IMAGE (ADA_ARG));
   end HI_THERE;

end FROM_C;

with FROM_C; -- **** WITH IS NECESSARY SO FROM_C GETS
				 -- **** INCLUDED IN PROGRAM
procedure MAIN is

	-- This is an Ada main procedure. it will call a C routine
	-- called GO_TO_C, passing the value 5 to that routine.

	-- GO_TO_C will call the Ada routine HI_THERE to demonstrate
	-- callbacks.

	-- The C routine that will call Ada:

	procedure GO_TO_C (C_ARG : in INTEGER);
	pragma INTERFACE (C, GO_TO_C);

begin

	-- Call C. C will the call Ada.
	GO_TO_C (5);

end MAIN;
---------------------------------------------------------------
COMPILER OUTPUT
--------------- CUT HERE --------------------------------------

---- HP9000s300 HP-UX Alsys Ada compiler V5.5 --------------------------------------------------------------------------------------

Source File : /se16/drb/SQ503/AdaC/callback.ada
Ada Library : /se16/drb/SQ503/AdaC/adac
Compiled on : 1992-08-26 19:36:08
Options     : SOURCE="callback.ada",LIBRARY="adac",ERRORS=50,LEVEL=UPDATE,CHECKS=ALL,GENERICS=INLINE,MEMORY=500,OUTPUT="callback.
              out",WARNING=YES,TEXT=YES,SHOW=ALL,DETAIL=YES,ASSEMBLY=NONE,INLINE=PRAGMA,REDUCTION=NONE,EXPRESSIONS=NONE,OBJECT=
              PEEPHOLE,TREE=NO,DEBUG=NO,COPY=NO,EDIT=NONE

                                                                                                      Next message at line:      10
------------------------------------------------------------------------------------------------------------------------------------


        1 with TEXT_IO;
        2 
        3 package FROM_C is
        4 
        5         -- Declaration of Ada routine HI_THERE, to be called
        6         -- from C. This must be in a library package.
        7 
        8         procedure HI_THERE (ADA_ARG : in INTEGER);
        9 
       10         pragma EXPORT (C, HI_THERE);
                                    <--1--->  
 1    *IDE The implementation defined pragma EXPORT is only allowed for an object declared by an object declaration. This pragma 
           has been ignored. - RM Appendix F.

       11 
       12 end FROM_C;
       13 
       14 package body FROM_C is
       15 
       16         procedure HI_THERE (ADA_ARG : in INTEGER) is
       17                 -- This procedure called from C. It will write a
       18                 -- message including the value passed into ADA_ARG.
       19    begin
       20                 TEXT_IO.PUT_LINE ("Now in Ada, call from C!");
       21                 TEXT_IO.PUT_LINE
       22                           ("integer passed was" & INTEGER'IMAGE (ADA_ARG));
       23    end HI_THERE;
       24 
       25 end FROM_C;
       26 
       27 with FROM_C; -- **** WITH IS NECESSARY SO FROM_C GETS
       28                                  -- **** INCLUDED IN PROGRAM
       29 procedure MAIN is
       30 
       31         -- This is an Ada main procedure. it will call a C routine
       32         -- called GO_TO_C, passing the value 5 to that routine.
       33 
       34         -- GO_TO_C will call the Ada routine HI_THERE to demonstrate
       35         -- callbacks.
       36 
       37         -- The C routine that will call Ada:
       38 
       39         procedure GO_TO_C (C_ARG : in INTEGER);
       40         pragma INTERFACE (C, GO_TO_C);
       41 
       42 begin
       43 
       44         -- Call C. C will the call Ada.
       45         GO_TO_C (5);
       46 
       47 end MAIN;
       48 
---- HP9000s300 HP-UX Alsys Ada compiler V5.5 --------------------------------------------------------------------------------------
/se16/drb/SQ503/AdaC/callback.ada
------------------------------------------------------------------------------------------------------------------------------------



  Number of diagnostics  Possible results  Severity level 

       1   warning       object code          (*)

       0   error         no object code       (**)

       0   error         analysis stopped     (***)

       0   fatal error   immediate abort      (****)



 No errors detected.  One warning issued. Compilation completed.
 ---------------------------------------------------------------


Faulty line is: 
------------------------------------------------------------------------------------------------------------------------------------

    *:10            
------------------------------------------------------------------------------------------------------------------------------------

--------------- CUT HERE --------------------------------------

-- 
Naasif Gierdien
ng@saturn.cs.swin.oz.au
Swinburne University of Technology, Hawthorn, Victoria, Australia.
Newsgroups: comp.lang.ada