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 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,90f687f65a66617e X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Simple ADA/C Question Date: 1997/03/04 Message-ID: #1/1 X-Deja-AN: 223022923 References: <01bc23b2$ecc64960$64e2b8cd@p5120.bda> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-03-04T00:00:00+00:00 List-Id: Keith argues for always using the interfaces type. Fine, I understand the argument, but there is no question that this leads to lots of extra code, and many people avoid it, and I don't think that's so terrible (no worse than using any other implementation dependent feature of a compiler. Probably Keith likes to stay away from all such -- but many users are quite content with adopting a style that is at least portable from GNAT to GNAT. Keith suggests << subtype Assertion is Boolean range True .. True; Integer_Same_Size : constant Assertion := Interfaces.C.int'Size = Standard.Integer'Size; >> Less writing, and guaranteed to not merely give a warning, but to be illegal if the assumption is violated is: X : Integer := 1 / Boolean'Pos (Interfaces.C.int'Size = Integer'Size); Note incidentally that Standard.Integer does not guarantee that you will get the integer in standard, there is no way to do that in general! So it is probably unnecssary pedantry. As for Keith's guess that there could be C compilers that disagree on int size, I doubt it. Keith are you aware of all the discussions going on around C sizes on 64-bit machines? In any case, a programmer who relies on int being the same as Integer is certainly on safe ground with GNAT, and I suspect in practice with other compilers too. There is a danger of excessive pedantry here, and I suspect Keith is worrying about something that in fact will not be a problem in practice. There are far more significant non-portabilities in porting of C than this one (the whole business of records being passed by copy being the most glaring!)