From: "Vadim Godunko" <vgodunko@vipmail.ru>
Subject: Re: Ada-kernel calls / IF & ELSE...
Date: Tue, 12 Mar 2002 00:09:13 +0300
Date: 2002-03-12T00:09:13+03:00 [thread overview]
Message-ID: <mailman.1015881063.32097.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: e7ebd224.0203111142.6801d352@posting.google.com
You MUST append ASCII.Nul if you pass any string parameters direct to
imported C routines.
For passing strings to C routines better use Interfaces.C.char_array type.
In package Interfaces.C you may found needed String<=>char_array conversion
routines, that automaticaly append/remove ASCII.Nul at the end of strings.
And, in you case, may be used standard Ada-POSIX bindings, that have open,
close, read, write,... functions.
This bindings for GNAT called Florist.
Regards,
Vadim
----- Original Message -----
From: "Karl Ran" <karlran1234@yahoo.com>
Newsgroups: comp.lang.ada
Sent: Monday, March 11, 2002 10:42 PM
Subject: Ada-kernel calls / IF & ELSE...
> Hi,
> I'm just starting to understand how to make Ada-kernel calls...
>
> Has anyone compiled the Kernel Calls demo on
> http://www.vaxxine.com/pegasoft/homes/13.html#13.5.4
> ?
>
> Here is a much simpler version:
>
> -----------------------------------------------------
> with Ada.Text_IO; use Ada.Text_IO;
>
> procedure audiocd is
>
> DevCDROM : constant string := "/dev/cdrom";
>
> type aFileID is new integer;
>
> procedure open( id : out aFileID;
> path : string;
> flags : integer );
>
> pragma import( C, open, "open");
> pragma import_valued_procedure( open );
>
> procedure perror( prefixstr : string );
> pragma import( C, perror, "perror");
>
> cd : aFileID;
>
> begin
>
> Put_Line( "Openning " & DevCDROM & "..." );
> Open( cd, DevCDROM, 0 );
>
> if cd < 0 then
> perror( "IF: Error openning CDROM drive " );
> else
> Put_Line( "ELSE: opened CDROM drive successfully " );
> end if;
>
> end audiocd;
> -----------------------------------------------------
>
> >gnatmake -gnatwa audiocd.adb
> gcc -c -gnatwa audiocd.adb
> gnatbind -x audiocd.ali
> gnatlink audiocd.ali
>
> >./audiocd
> Openning /dev/cdrom...
> IF: Error openning CDROM drive ELSE: opened CDROM drive successfully :
> No such file or directory
>
>
> Would someone please explain whats going on here?
>
> Is this just because of my bleeding-edge-suse71-gnat3.14p-unsupported
> system or is normal?
>
>
> Karl
next prev parent reply other threads:[~2002-03-11 21:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-11 19:42 Ada-kernel calls / IF & ELSE Karl Ran
2002-03-11 20:41 ` Bj�rn Lundin
2002-03-12 15:09 ` Karl Ran
2002-03-12 20:16 ` Vadim Godunko
2002-03-11 21:06 ` Vadim Godunko
2002-03-11 21:06 ` Vadim Godunko
2002-03-11 21:07 ` Vadim Godunko
2002-03-11 21:09 ` Vadim Godunko [this message]
2002-03-11 21:09 ` Vadim Godunko
2002-03-11 21:17 ` Sorry for repeat " Vadim Godunko
2002-03-12 15:01 ` Karl Ran
2002-03-12 0:34 ` Adrian Knoth
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox