TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mime-Version: 1.0
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date: Tue, 4 Mar 2003 12:53:12 +0100
Reply-To: Laurent Guerby <[log in to unmask]>
From: Laurent Guerby <[log in to unmask]>
In-Reply-To: <[log in to unmask]>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain
Parts/Attachments: text/plain (44 lines)
On Tue, 2003-03-04 at 06:27, Steven Lim wrote:

> I tried to import
>
> Pragma Import (C, MyProc, "ProcedureExportedName");
> and desperately also trying
> Pragma Import (C, MyProc, "?Procedure ExportedName@@YGHXZ");
>
> Both to no avail... I've tried using CPP too..
>
> Please advise..

The convention for DLLs is likely to be not C but Stdcall. FYI, one
chapter from the manual:

<<
The name to use on the Ada side when importing a C routine with a
@code{Stdcall} calling convention is the name of the C routine. The leading
underscore and trailing @code{@@}@code{@i{nn}} are added automatically by
the compiler. For instance the Win32 function:

@smallexample
@b{APIENTRY} int get_val (long);
@end smallexample

@noindent
should be imported from Ada as follows:

@smallexample
@group
@b{function} Get_Val (V : Interfaces.C.long) @b{return} Interfaces.C.int;
@b{pragma} Import (Stdcall, Get_Val);
--  @i{On the x86 a long is 4 bytes, so the Link_Name is }"_get_val@@4"
@end group
@end smallexample
>>

Please do spend some time getting a tiny Ada and tiny C program to
cooperate while reading the manual, a lot of people have done this
successfully, you should be able too :).

--
Laurent Guerby <[log in to unmask]>

ATOM RSS1 RSS2