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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,39ade949adb6bf4 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: StdCall and pragma Import_Function Date: Fri, 19 Aug 2011 11:10:27 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <332032a4-0acf-459d-a743-e90e823ca5af@glegroupsg2000goo.googlegroups.com> NNTP-Posting-Host: 1d351f7dc72217294d4c4c8c9fbe9342 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: a1289b3082d12e439df9938ebfaea29b X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: <332032a4-0acf-459d-a743-e90e823ca5af@glegroupsg2000goo.googlegroups.com> X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=a1289b3082d12e439df9938ebfaea29b X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news1.google.com comp.lang.ada:20685 Date: 2011-08-19T11:10:27-07:00 List-Id: 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