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,FREEMAIL_FROM,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6e761c7f5b11579,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-03 03:04:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!dialin-145-254-224-177.arcor-ip.NET!not-for-mail From: "Henrik Quintel" Newsgroups: comp.lang.ada Subject: C Interface Date: Wed, 3 Apr 2002 13:05:05 +0200 Message-ID: NNTP-Posting-Host: dialin-145-254-224-177.arcor-ip.net (145.254.224.177) X-Trace: fu-berlin.de 1017831883 29093923 145.254.224.177 (16 [79136]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Xref: archiver1.google.com comp.lang.ada:22044 Date: 2002-04-03T13:05:05+02:00 List-Id: Dear all, I have a large C program and want to use the C Bindings win32ada for the GNAT 3.13p. I have insatlled GNAT and the Bindings in a correct way. In the standard I have found the following example about the C function strcpy: -- Example of using the Interfaces.C package: -- Calling the C Library Function strcpy with Interfaces.C; procedure Test is package C renames Interfaces.C; use type C.char_array; -- Call strcpy: -- C definition of strcpy: char *strcpy(char *s1, const char *s2); -- This function copies the string pointed to by s2 (including the terminating null character) -- into the array pointed to by s1. If copying takes place between objects that overlap, -- the behavior is undefined. The strcpy function returns the value of s1. -- Note: since the C function's return value is of no interest, the Ada interface is a procedure procedure Strcpy (Target : out C.char_array; Source : in C.char_array); pragma Import(C, Strcpy, "strcpy"); Chars1 : C.char_array(1..20); Chars2 : C.char_array(1..20); begin Chars2(1..6) := "qwert" & C.nul; Strcpy(Chars1, Chars2); -- Now Chars1(1..6) = "qwert" & C.Nul end Test; This example works very fine with my compiler. Now, I have tried to display the contents of Chars1 but I don't know how. I have tried several ways but no one worked. Additional, I have several problems to understand the example above. If I want to interface to the function Strlen - Prototype is: function Strlen (Item : in chars_ptr) return size_t; what can I do get access to it. Can someone explain me a general way what to do to interface C functions in Ada? I have read the online help that comes along with win32ada, but the explanation is not so good. Does someone knows if there are examples which explain the access to the C interface functions. It would be very nice if someone can give me references or examples. Thanks for all in advance. Yours Henrik