From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: pragma Convention questions
Date: Sun, 11 Nov 2007 20:14:24 +0100
Date: 2007-11-11T20:14:24+01:00 [thread overview]
Message-ID: <2451589.tWPigV6bxQ@linux1.krischik.com> (raw)
In-Reply-To: 87sl3cd9cw.fsf@willow.rfc1149.net
Samuel Tardieu wrote:
> I have several questions regarding pragma Convention in Ada95 for
> language lawyers.
The language lawyers are on mailto: ada-comment@ada-auth.org ;-)
> 1- pragma Convention on private types in language-define packages
>
> Is it allowed for a compiler implementor to use a pragma Convention
> on a private type in a language-defined package?
>
> For example, would it be allowed to use
>
> pragma Convention (C, chars_ptr);
Yes. However the type must not be used beforehand - which is unlikely. Real
language lawyers can tell you the term after which a type can not have any
further modifications.
> in the private part of Interfaces.C.Strings? (the real motive to this
> question is to get rid of a warning in GNAT about conversion between
> pointers of different conventions -- the type is already compatible
> with C as per RM B3.1(1))
>
> 2- pragma Convention, renaming and Intrinsic
>
> Is the following code legal?
>
> package U is
> type Foo is (Foo1, Foo2);
> function F return Foo renames Foo1;
> pragma Convention (Ada, F);
> type Foo_Access is access function return Foo;
> X : Foo_Access := F'Access;
> end U;
>
> GNAT rejects X initialization with 'prefix of "Access" attribute
> cannot be intrinsic'. Which means that the pragma Convention failed
> silently. Is it allowed to have it fail without a compilation error?
> Or is the 'Access legal?
This is a different problem. F does not actually exist and therefore has no
address to access. And for "Convention Ada" that's ok. What you really
meant to do is:
pragma Export (Ada, F);
But somehow I think that will fail because F does exists physically. Same
way you can do:
enum Foo {Foo1, Foo2};
#define F Foo1
Foo *X = &F;
in C. (I take it you know C).
Martin
--
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com
next prev parent reply other threads:[~2007-11-11 19:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-11 16:39 pragma Convention questions Samuel Tardieu
2007-11-11 19:14 ` Martin Krischik [this message]
2007-11-11 20:57 ` Samuel Tardieu
2007-11-12 8:14 ` Martin Krischik
2007-11-12 8:30 ` Samuel Tardieu
2007-11-12 17:02 ` Adam Beneschan
2007-11-12 21:54 ` Samuel Tardieu
2007-11-15 5:06 ` Randy Brukardt
2007-11-15 7:55 ` Samuel Tardieu
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox