comp.lang.ada
 help / color / mirror / Atom feed
* Are 'pragma Export' and access types mutually exclusive?
@ 1997-08-08  0:00 Tom Weis
  1997-08-08  0:00 ` Robert A Duff
  1997-08-09  0:00 ` Robert Dewar
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Weis @ 1997-08-08  0:00 UTC (permalink / raw)



I'm using gnat-3.09-sparc-sun-sun0s4.1.3-bin.tar.gz.
 
I would like to define a procedure in a package and make
it visible:
  1) to a C program (via pragma Export)
  2) to an Ada program (via an access type)
 
The GNAT compiler gives an error when I try to make
a procedure visible in both fashions simultaneously:
 
Error Message:
-------------
package1.ads:10:25: subprogram has invalid convention for context
 
 
If I comment out the 'pragma Export' the compilation
error goes away and the program compiles and links.
Should "pragma Export (C, proc)" and "proc'access" be
mutually exclusive?  Are all bets off the table when you
invoke a pragma with respect to other Ada primitives?
 
P.S. I'm using this simplified version of the package to
reduce the size of the example code.  My hope would be to
eventually have a structure with multiple access types
populated by many functions from multiple packages.  So
I'm not interested in responses which say use
Package.Procedure to refer to the procedure in Ada. I'd
like to keep the discussion on point.  Thanks.
 
--================================================
-- package1.ads
--================================================
package Package1 is
 
   procedure Integer_Procedure1(Arg_In : in out Integer);
   procedure Integer_Procedure2(Arg_In : in out Integer);
   pragma Export(C, Integer_Procedure2,
                    "Integer_Procedure2");
 
   type fcn_access
     is access procedure (Arg_In: in out Integer);
 
   fcn1 : fcn_access := Integer_Procedure1'access;
   fcn2 : fcn_access := Integer_Procedure2'access;
 
end Package1;
--================================================
-- package1.adb
--================================================
with Ada.Integer_Text_IO;
with Ada.Text_IO;
 
package body Package1 is
 
   procedure Integer_Procedure1(Arg_In : in out Integer)
is
   begin
      Ada.Integer_Text_IO.Put(Arg_In);
      Ada.Text_IO.New_Line;
   end Integer_Procedure1;
 
   procedure Integer_Procedure2(Arg_In : in out Integer)
is
   begin
      Ada.Integer_Text_IO.Put(Arg_In);
      Ada.Text_IO.New_Line;
   end Integer_Procedure2;
 
end Package1;
--================================================
-- main.adb
--================================================
with Ada.Integer_Text_IO;
with Ada.Text_IO;
with Package1;
 
procedure main is
   Integer_Arg : Integer := 10;
begin
   -- Call Package1.Integer_Procedure1 with access type
   Package1.fcn1.all(Integer_Arg);
end main;




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-08-09  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-08-08  0:00 Are 'pragma Export' and access types mutually exclusive? Tom Weis
1997-08-08  0:00 ` Robert A Duff
1997-08-09  0:00 ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox