From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a657bb3cf254ae38,start X-Google-Attributes: gid103376,public From: Tom Weis Subject: Are 'pragma Export' and access types mutually exclusive? Date: 1997/08/08 Message-ID: <33EBA058.5680@mathworks.com>#1/1 X-Deja-AN: 262961144 Organization: The MathWorks, Inc. Newsgroups: comp.lang.ada Date: 1997-08-08T00:00:00+00:00 List-Id: 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;