comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: StdCall and pragma Import_Function
Date: Fri, 19 Aug 2011 11:10:27 -0700
Date: 2011-08-19T11:10:27-07:00	[thread overview]
Message-ID: <j2m90i$7jc$1@tornado.tornevall.net> (raw)
In-Reply-To: <332032a4-0acf-459d-a743-e90e823ca5af@glegroupsg2000goo.googlegroups.com>

On 08/19/2011 09:24 AM, Felix Krause wrote:
> I'm writing a cross-platform Ada binding for a C library. It currently works on OSX and Linux, and I'm trying to get it to work on Windows. I have some code like this:

The first rule when interfacing to another language is to only use types 
declared as having the convention of that language.

> package P is
>     type ULong is mod 2 ** 64;
>     for ULong'Size use 64;

pragma Convention (C, Ulong);

>     type Bit_Vector is record
>        First_Bit  : Boolean;
>        Second_Bit : Boolean;
>     end record;
>     for Bit_Vector use record
>        First_Bit  at 0 range 0 .. 0;
>        Second_Bit at 0 range 1 .. 1;
>     end record;
>     for Bit_Vector'Size use ULong'Size;

pragma Convention (C_Pass_By_Copy, Bit_Vector);

>     function C_Function (Param : Bit_Vector) return ULong;
>     pragma Import (StdCall, C_Function, "cFunc");
>     pragma Import_Function (Internal =>  C_Function, External =>  "cFunc", Mechanism =>  (Param =>  Value));

Import_Function is not a standard pragma. C_Pass_By_Copy is standard, and seems 
to do the same thing.

> end P;

-- 
Jeff Carter
"Blessed is just about anyone with a vested interest in the status quo."
Monty Python's Life of Brian
73



  parent reply	other threads:[~2011-08-19 18:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 16:24 StdCall and pragma Import_Function Felix Krause
2011-08-19 16:51 ` Dmitry A. Kazakov
2011-08-19 17:07   ` Felix Krause
2011-08-19 18:58     ` Dmitry A. Kazakov
2011-08-19 19:23       ` Felix Krause
2011-08-19 19:43         ` Dmitry A. Kazakov
2011-08-19 20:07           ` Felix Krause
2011-08-19 20:37             ` Dmitry A. Kazakov
2011-08-19 20:45             ` Jeffrey Carter
2011-08-21 18:25               ` Felix Krause
2011-08-20  8:04           ` Georg Bauhaus
2011-08-20  9:23             ` Dmitry A. Kazakov
2011-08-19 17:26   ` Adam Beneschan
2011-08-19 17:38     ` Felix Krause
2011-08-19 18:10 ` Jeffrey Carter [this message]
2011-08-19 18:37   ` Felix Krause
replies disabled

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