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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1d485db3760413be X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-17 15:39:45 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: prichtmyer@yahoo.com (Peter Richtmyer) Newsgroups: comp.lang.ada Subject: Re: Compiler default initialization of array types Date: 17 Oct 2002 15:39:44 -0700 Organization: http://groups.google.com/ Message-ID: <1b585154.0210171439.47ab4605@posting.google.com> References: NNTP-Posting-Host: 164.223.72.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1034894384 25150 127.0.0.1 (17 Oct 2002 22:39:44 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 17 Oct 2002 22:39:44 GMT Xref: archiver1.google.com comp.lang.ada:29885 Date: 2002-10-17T22:39:44+00:00 List-Id: Lutz Donnerhacke wrote in message news:... > * Sebastian wrote: > > I wonder if Ada always assignes Array types with default values? > > It can happen. > > > In case this is true; is there some way to suppress this feature? > > pragma Import(Ada, array_variable); -- directly after the definition. I have used the "Pragma Import" successfully in some circumstances, but for a simple array, Gnat would not allow it. The error message looks strange to me, maybe a "bug". See below. (Gnat does not assign default values, the example shows what happens if values are assigned in the array using the record...) with text_io; procedure artest is type r is record i: integer := 1; end record; pragma pack (r); for r'size use 32; type a_t is array (1 .. 2) of r; for a_t'size use 64; type i_t is array (1 .. 2) of integer; for i_t'size use 64; b : a_t; -- pragma import (Ada, b); -- Gnat 3.14p NOT LEGAL: artest.adb:17: undefined reference to `b' c : i_t := (others => 3); d : a_t; for d'address use c'address; e : i_t := (others => 5); f : a_t; for f'address use e'address; pragma import (Ada, f); begin for j in a_t'range loop text_io.put_line ("-- b(" & integer'image(j) & ").i is " & integer'image(b(j).i)); text_io.put_line ("-- d(" & integer'image(j) & ").i is " & integer'image(d(j).i)); text_io.put_line ("-- f(" & integer'image(j) & ").i is " & integer'image(f(j).i)); text_io.put_line ("-- --------------------"); end loop; -- b( 1).i is 1 -- d( 1).i is 1 -- f( 1).i is 5 (THE PRAGMA SUPPRESSED INITIALIZATION) -- -------------------- -- b( 2).i is 1 -- d( 2).i is 1 -- f( 2).i is 5 -- -------------------- end artest; Peter