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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bc010a2bdba758e8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-11 13:08:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!deine.net!freenix!enst!enst.fr!not-for-mail From: "Vadim Godunko" Newsgroups: comp.lang.ada Subject: Re: Ada-kernel calls / IF & ELSE... Date: Tue, 12 Mar 2002 00:07:07 +0300 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1015880885 7093 137.194.161.2 (11 Mar 2002 21:08:05 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 11 Mar 2002 21:08:05 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Original-Cc: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:21082 Date: 2002-03-12T00:07:07+03:00 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" 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