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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,463c5796782db6d8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-09 01:10:07 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: [Spark] Arrays of Strings Date: Wed, 9 Apr 2003 08:10:06 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1049875806 17616 217.17.192.37 (9 Apr 2003 08:10:06 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Wed, 9 Apr 2003 08:10:06 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:36006 Date: 2003-04-09T08:10:06+00:00 List-Id: * Eric G. Miller wrote: > In , Lutz Donnerhacke wrote: > >> In order to implement thin an execve binding, I wonder how to emulate the >> C-Type "char const * const x []". Any bright ideas? > > Errm, my local definition of execve looks like: > > int execve(const char *filename, > char *const argv [], char *const envp[]); > > What'd the const pointer be for? Even if your definition had such, that'd > be a burden upon the C function, but shouldn't much affect the Ada side of > things. "char const * const []" is an array of constant pointers to constant chars. The modifier const is a postfix modifier. For the first element an equivalent prefix notation exists for syntactic shugar. > Try the following out (rename "/tmp/hello" as appropriate)... > > with Ada.Text_Io; > with Interfaces.C.Strings; The use of this packages is not possible in Spark. I need an emulation or shadow of the package Interfaces.C.Strings. > use Ada.Text_Io; "use package" is not allowed in Spark. > Argv : C.Strings.Chars_Ptr_Array := > (C.Strings.New_String("John"), > C.Strings.New_String("Bill"), > C.Strings.New_String("Bob"), > C.Strings.Null_Ptr); This involves dynamic memory, which should be avioded as much as possible in Spark. Language based dynamic memory management is not supported in Spark. I hope it's clear, what I expect: package Interfaces is end Interfaces; package Interfaces.C is type int is range Integer'First .. Integer'Last; -- has to be correct. end Interfaces.C; package Interfaces.C.Strings is type Chars_Ptr is private; type Chars_Ptr_Array is array (Positive range <>) of Chars_Ptr; private type Chars_Ptr is mod 2**32; -- has to be correct. end Interfaces.C.Strings; with Interfaces.C.Strings; --# inherit Interfaces.C.Strings, Interfaces.C; package Executor is function Execve ( Filename : Interfaces.C.Strings.Chars_Ptr; Argv : Interfaces.C.Strings.Chars_Ptr_Array; Envp : Interfaces.C.Strings.Chars_Ptr_Array) return Interfaces.C.Int; pragma Import (Convention => C, Entity => Execve, External_Name => "execve"); end Executor;