From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Interfaces.C
Date: 1996/08/11
Date: 1996-08-11T00:00:00+00:00 [thread overview]
Message-ID: <01bb8790$54d1da20$368371a5@dhoossr.iquest.com> (raw)
In-Reply-To: DvwyEs.2vw@cerc.wvu.edu
Hi David,
here is a quick and dirty example. Of course, Ada itself has better
facilities for printing, than the c-library's printf, but this illustrates
some c interfaces. Hoe this helps -- the example even includes pointers ;)
with Interfaces.C;
with System;
with Text_IO;
procedure demo_interfaces_c is
ada_format_string : constant string := "This is a C format string with a
long float" &
" format specification %lf" & ascii.LF;
function printf (
format_string_address : system.address;
long_float_value : long_float
) return integer;
pragma interface (C, printf);
return_value : integer;
c_format_string : Interfaces.C.char_array (0 ..
ada_format_string'length);
begin
c_format_string := Interfaces.C.To_C (ada_format_string);
return_value := printf (c_format_string'Address, long_float
(3.141592654));
Text_IO.Put_Line ("printf return value =>" &
integer'image(return_value));
end demo_interfaces_c;
--
David C. Hoos, Sr.,
http://www.dbhwww.com
http://www.ada95.com
David Krovich <dkrovich@cs.wvu.edu> wrote in article
<DvwyEs.2vw@cerc.wvu.edu>...
>
> I'm looking for source code examples for using the interfaces.C
> package. Any pointers would be appreciated.
>
> I've already printed out the Interfaces to Other Languages
> section from the Ada 95 Reference manual, so please don't just point
> me towards that.
>
> Thanks.
>
> ---------------------------------------------------------------------
> ------David Krovich-----------------------Computer Science Major-----
> ----dkrovich@cs.wvu.edu------------------West Virginia University----
> ---------------------------------------------------------------------
>
>
>
>
next prev parent reply other threads:[~1996-08-11 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-10 0:00 Interfaces.C David Krovich
1996-08-11 0:00 ` David C. Hoos, Sr. [this message]
1996-08-14 0:00 ` Interfaces.C Mike Fair
-- strict thread matches above, loose matches on Subject: below --
1994-11-01 15:50 Interfaces.C Ken Thomas
1994-11-01 22:45 ` Interfaces.C Dale Stanbrough
1994-11-02 13:34 ` Interfaces.C Robb Nebbe
1994-11-06 1:15 ` Interfaces.C Dale Stanbrough
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox