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,c11f3836a5a201d3 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-11 14:22:39 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!rcn!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail From: Charles Hixson Subject: Re: Circular type definition problem Newsgroups: comp.lang.ada References: <1s7V6.4021$Il5.510814@newsread1.prod.itd.earthlink.net> User-Agent: KNode/0.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Message-ID: Date: Mon, 11 Jun 2001 21:18:25 GMT NNTP-Posting-Host: 63.183.9.224 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 992294305 63.183.9.224 (Mon, 11 Jun 2001 14:18:25 PDT) NNTP-Posting-Date: Mon, 11 Jun 2001 14:18:25 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Mon, 11 Jun 2001 14:16:22 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:8575 Date: 2001-06-11T21:18:25+00:00 List-Id: But the purpose of the Count type declared in Direct_IO is to list record indicies, which is what I'm doing. Unfortunately, as far as I can see, the type doesn't exist until I specialize it with: package Node_IO is new Ada.Direct_IO(Block); But I want an index to the block (i.e., next_node) to be contained within the Block. What I'm trying to avoid is defining an excessive number of types. This is a type that is defined by the system to mean exactly what I want it to mean. But I don't seem to be able to use it. The reason that I tried the code that I did is because it is an exact parallel with Access allocation. (And I don't think that I can refer to System.Direct_IO.Count'Last;, as I haven't yet got block defined. OTOH, if I can refer to System.Direct_IO.Count'Last; , then could I refer to the type System.Direct_IO.Count, and thus use my original code with only the addition of System.Dire... instead of Ada.Dire... But then, again, would this mean that I would be needing to use Unchecked_Conversion when I wanted to refer to a particular record? (This is one of the things that I wanted to avoid.) Martin Dowie wrote: > you could split out the implementation specifics into a seperate > package e.g. > > with System.Direct_IO; > > package Project_Specifics is > > -- Specific to GNAT > -- > Direct_IO_Count_Last : constant := > System.Direct_IO.Count'Last; > > end Project_Specifics; > > > with Ada.Direct_Io; > with Project_Specifics; > > package Temp is > > type Byte is mod 256; > > type Block; > > type Blockdata is array (0 .. 511) of Byte; > > type Node_Count is range 0 .. > Project_Specifics.Direct_IO_Count_Last; > > type Block is > record > Next_Node : Node_Count; > Data : Blockdata; > end record; -- Block > > pragma Pack(Blockdata); > pragma Pack(Block); > > package Node_Io is new Ada.Direct_Io(Block); > use Node_Io; > > end Temp; > > > "Charles Hixson" wrote in message > news:1s7V6.4021$Il5.510814@newsread1.prod.itd.earthlink.net... >> This is what I'm trying to do: >> type Block; >> package Node_IO is new Ada.Direct_IO(Block); >> use Node_IO; >> type BlockData is array (0..511) of Byte; >> type Block is record >> next_node : Node_IO.Count; >> data : BlockData; >> end record; -- Block >> pragma pack(BlockData); >> pragma pack(Block); >> >> Not too much to my surprise, it didn't work. Node_IO needs to >> be >> defined with a real type. OTOH, the type Node_IO.Count is >> defined within Node_IO, so I can't put it after the declaration >> of Block. >> >> I suppose that I could just give up, and declare next_node to >> be >> Long_Integer, but that seems so inelegant. Node_IO.Count is, >> essentially, an Access variable (it says where in the file to >> find the next Block). But I'm not really sure how to approach >> this. Any suggestions?