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-Thread: a07f3367d7,c689b55786a9f2bd X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!k29g2000yqh.googlegroups.com!not-for-mail From: Gautier write-only Newsgroups: comp.lang.ada Subject: Re: for S'Image use Func?? Date: Tue, 11 May 2010 12:56:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <58bc837c-16b5-4a9d-af74-40417ad538c5@k29g2000yqh.googlegroups.com> References: <4be417b4$0$6992$9b4e6d93@newsspool4.arcor-online.net> <1qcb6z4i20dyb.1dz2hd4c0vx69.dlg@40tude.net> NNTP-Posting-Host: 85.1.158.26 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1273607762 5675 127.0.0.1 (11 May 2010 19:56:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 11 May 2010 19:56:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k29g2000yqh.googlegroups.com; posting-host=85.1.158.26; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.9) Gecko/20100317 SeaMonkey/2.0.4,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:11527 Date: 2010-05-11T12:56:02-07:00 List-Id: On May 11, 12:39=A0am, Yannick Duch=EAne (Hibou57) wrote: [...] > Well, to be honest, this is not exactly the same as with C, as =A0 > Ada.Streams.Stream_Element is implementation defined (which is good, =A0 > because this is indeed platform dependent), so you will need an Assert = =A0 > pragma somewhere is your application, which ensures =A0 > Ada.Streams.Stream_Element is 8 bits or at least 8 bits (this is, in most= =A0 > of case), and then convert from Ada.Streams.Stream_Element to your =A0 > Byte_Type or anything your application defined as such. As Dmitry already wrote, you usually don't need to bother about it: just use the stream attributes: Byte'Read/'Write(stream, b) and don't worry at all about Stream_Element being 8 bits or not... There are two exceptions I know: - the Read in Ada.Streams gives the number of bytes actually read when a stream reach its end - in some implementations, Byte_array'Read/'Write are utterly slow compared to the procedures in Ada.Streams. Anyway, you don't need to bet or assume that Ada.Streams.Stream_Element is 8 bits. You can make a size check (even a compile-time one!). Here, for arrays: subtype Size_test_a is Byte_Array(1..19); subtype Size_test_b is Ada.Streams.Stream_Element_Array(1..19); -- is_mapping_possible: constant Boolean:=3D Size_test_a'Size =3D Size_test_b'Size and then Size_test_a'Alignment =3D Size_test_b'Alignment; ______________________________________________________________ Gautier's Ada programming -- http://gautiersblog.blogspot.com/ NB: For a direct answer, e-mail address on the following web site: http://www.fechtenafz.ethz.ch/wm_email.htm