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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Need a way to convert a constant to a variable Date: Sat, 5 Aug 2017 17:41:20 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 5 Aug 2017 15:37:15 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e2d8a2245c1ff735efa82028d286fec1"; logging-data="15340"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IHC4hXwoLQWeMwG19CKsmD//7nMZwbVg=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 In-Reply-To: X-Antivirus-Status: Clean Content-Language: en-US X-Antivirus: AVG (VPS 170804-2, 08/04/2017), Outbound message Cancel-Lock: sha1:qpnUEe4TSyGkiHv4z27B0iueZ74= Xref: news.eternal-september.org comp.lang.ada:47609 Date: 2017-08-05T17:41:20+02:00 List-Id: On 08/05/2017 03:41 PM, Victor Porton wrote: > > Write a function with an "in" indefinite holder with a string, return > chars_ptr corresponding to the string. Your requirements are for an indefinite holder with a string, but your attempted solution is for an indefinite holder with a char_array. I will assume you meant an indefinite holder with a char_array. > It looks like there is no solution of this in Ada 2012 :-( with Ada.Containers.Indefinite_Holders; with Interfaces.C.Strings; package Conv is package C_Str_Holders is new Ada.Containers.Indefinite_Holders (Element_Type => Interfaces.C.Char_Array, "=" => Interfaces.C."="); function To_Chars_Ptr (Item : C_Str_Holders.Holder) return Interfaces.C.Strings.Chars_Ptr is (Interfaces.C.Strings.New_Char_Array (Item.Element) ); end Conv; This compiles fine, so clearly there is a way to do this without a language change. -- Jeff Carter "He didn't get that nose from playing ping-pong." Never Give a Sucker an Even Break 110 --- This email has been checked for viruses by AVG. http://www.avg.com