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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, LOTS_OF_MONEY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,45a9122ddf5fcf5 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Rules for Representation of Subtypes Date: 1996/09/23 Message-ID: #1/1 X-Deja-AN: 184853079 references: <01bba947$d8990620$188371a5@dhoossr.iquest.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-09-23T00:00:00+00:00 List-Id: In article <01bba947$d8990620$188371a5@dhoossr.iquest.com>, David C. Hoos, Sr. wrote: >My understanding of the rules for representation clauses for types is that >the size attribute may only be specified for the first subtype, so for any >subtype of integer you would get the same size as Integer. No, that's not quite right. You're right about the rules for rep clauses. But that certainly does *not* imply that all subtypes of integer have the same size as Integer -- you can't *ask* the compiler to use 8 bits for a subtype of Integer, but the compiler can use 8 bits. In fact, 13.3(55) requires that they do *not* have the same size, in general. Besides, the A_Small_Integer in the example was a variable, not a subtype. You can specify its size as 8 bits, if you want. Or 32 bits. Also, it's good to keep in mind that if you have subtype S and object X of subtype S, it is NOT always the case that S'Size = X'Size. In fact, it is unusual for these to be equal. >In fact, I just tried to specify a size of 8 bits for your object >"A_Small_Integer", with gnat 3.04a on Win95, and found that the compiler >gave no warning, and ignored the clause. Printing out the 'size attribute >yielded 32. GNAT is not the definition of the Ada language. ;-) >However, as far as your "UNIX" example is concerned (I say "UNIX", because >this would apply to any OS where you're doing what you appear to be doing >here -- i.e. interfacing to the C library), why not write the code in a >manner where it doesn't matter how the compiler represents the object -- >i.e., write: > > read (fd, A_Small_Integer'Address, A_Small_Integer'Size / >System.Storage_Unit); Yes, that's better than "4". - Bob