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 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Are 'pragma Export' and access types mutually exclusive? Date: 1997/08/08 Message-ID: #1/1 X-Deja-AN: 262969611 References: <33EBA058.5680@mathworks.com> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-08-08T00:00:00+00:00 List-Id: In article <33EBA058.5680@mathworks.com>, Tom Weis wrote: > 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; You need to make the access type have the same calling convention as the subprograms. By default, fcn_access has convention Ada, so use "pragma Convention(C, fcn_access);". You will then need to use pragma Convention on Integer_Procedure1, too. If X is of type fcn_access, then when the compiler sees a call to X.all, it needs to know where to put the parameters and so forth -- that is, it needs to know the calling convention. It can't be both C and Ada -- it has to be one or the other. The compiler doesn't know where that access value came from, so the matching-conventions rule is necessary. - Bob