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,79db4ff72bff9422 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-28 17:42:42 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: joseph_kwan@greenlime.com (Joseph Kwan) Newsgroups: comp.lang.ada Subject: Re: How to convert record? Date: 28 Oct 2001 17:42:41 -0800 Organization: http://groups.google.com/ Message-ID: <80d2e34.0110281742.1bf0bfa7@posting.google.com> References: <80d2e34.0110210156.7918cd3d@posting.google.com> <3bd402f9.8783319@news.demon.co.uk> <80d2e34.0110250340.155ae0b7@posting.google.com> NNTP-Posting-Host: 210.186.172.54 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1004319762 26021 127.0.0.1 (29 Oct 2001 01:42:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 29 Oct 2001 01:42:42 GMT Xref: archiver1.google.com comp.lang.ada:15321 Date: 2001-10-29T01:42:42+00:00 List-Id: "David C. Hoos" wrote in message news:... > Presumably, you know the size of the record. In your original post > you showed a record with 8 bytes. > > So, you would declare a constrained string subtype of the correct size > e.g., subtype Record_String is POSIX.POSIX_String (1 .. 8); > > Now you can instantiate Unchecked_Conversion from the Record to > Record_String, because Record_String is constrained. > > A Record_String is a valid buffer to pass to POSIX.IO.Read. So, it must be a constrained type/subtype. This solve my problems. Thanks. OTOH, I read about 13.13.2 Stream-Oriented Attributes in LRM. Can I use 'Read and 'Write or 'Input and 'Output for [this] purpose? Can someone please explain in details (an example of the implementation will be of great help) how to implement these attributes? Please forgive my stupidity because I can't find a good examples of such implementation in books and LRM and certainly am unable to figure it out. Thank you. > > > > I thought that would work too but theoretically, > > Ada.Unchecked_Conversion will not work in converting record to > > POSIX.IO.IO_Buffer which is a string of characters (See spec in > > florist's implementation). > > > > Anyhow I tried to do Unchecked_Conversion and gnat gave me error > > message: > > > > "unchecked conversion to unconstrained array not allowed".