TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Show All Mail Headers

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

Print Reply
Subject:
From:
Laurent Guerby <[log in to unmask]>
Reply To:
Laurent Guerby <[log in to unmask]>
Date:
Tue, 4 Mar 2003 12:53:12 +0100
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