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-Thread: 103376,fd173879a595bde X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!cycny01.gnilink.net!cyclone1.gnilink.net!spamkiller.gnilink.net!gnilink.net!trnddc08.POSTED!20ae255c!not-for-mail Newsgroups: comp.lang.ada From: Anonymous Coward Subject: Re: pragma convention References: <87y8435fve.fsf@code-hal.de> Message-Id: User-Agent: slrn/0.9.7.4 (Linux) Date: Sun, 06 Nov 2005 22:22:18 GMT NNTP-Posting-Host: 141.149.78.234 X-Complaints-To: abuse@verizon.net X-Trace: trnddc08 1131315738 141.149.78.234 (Sun, 06 Nov 2005 17:22:18 EST) NNTP-Posting-Date: Sun, 06 Nov 2005 17:22:18 EST Xref: g2news1.google.com comp.lang.ada:6258 Date: 2005-11-06T22:22:18+00:00 List-Id: In article , Jeffrey R. Carter wrote: > > pragma Convention (X, ... > > really means the convention used by some specific X compiler chosen > by the Ada compiler developers for those cases where the X language > does not rigorously specify the characteristic in question. I find it interesting that pragma Convention even appears in the ARM, considering there is no definite behavior required for it. It seems it would be more appropriate to not even mention it in the ARM, and let the compiler implementors decide whether to have it. Or if pragma Convention should be mentioned in the ARM, it should be rewritten. I would rewrite this: ARM B.1.21 If pragma Convention applies to a type, then the type shall either be compatible with or eligible for the convention specified in the pragma. to state something like: If pragma Convention applies to a type, then the type shall be compatible with conventions specified in the pragma for languages that have a convention. For other languages, pragma Convention is to be offered at the discretion of the compiler authors. >From there, it would be useful to have a list of languages that have default representations, so ADA programmers know when they can expect some precise behavior from pragma convention. > Convention C does do certain common things for you. For an access > type, you insure that it is just a pointer, and doesn't contain any > additional data (which Ada's access values can and sometimes do > contain). That's useful to know.. but why doesn't the ARM lay down the rule on that? It seems largely like guesswork to know what to expect from pragma convention. Is there a way to explicitly define a pointer in ADA to be a raw address as it is for C, without the pragma convention? Is that what system.address is? > For subprograms, you get automatic conversion of parameters to > pointers to match C passing rules and make [in] out parameters work > properly. > > This latter is very useful; you can write > > procedure C (X : out Interfaces.C.Int); > pragma Import (C, X, "xInC"); > > and the compiler takes care of passing a pointer for you. Parameter modes are handled entirely by pragma import, correct? I'm not sure what pragma convention does in that respect. Someone stated earlier that pragma convention will ensure order is preserved for records types passed to pragma convention, but the GNAT manual states that pragma Convention has no effect on records: http://gcc.gnu.org/onlinedocs/gcc-3.3.5/gnat_rm/Effect-of-Convention-on-Representation.html I find it frustrating to work with loosely defined characteristics in ADA. At this point, I'll continue to use pragma convention for the heck of it, but ultimately it seems I cannot solely rely on it to do anything, and I should be rep specing records and enum sizes anyway.