comp.lang.ada
 help / color / mirror / Atom feed
From: Christoph Grein <christoph.grein@eurocopter.com>
Subject: Re: Help: Type not accessible
Date: Tue, 19 Mar 2002 15:45:13 +0100 (MET)
Date: 2002-03-19T15:45:13+01:00	[thread overview]
Message-ID: <mailman.1016549221.9616.comp.lang.ada@ada.eu.org> (raw)

> procedure Main is
> 
>     Mynav : aliased Nav;
> 
>     Pointer_To_Nav : Navpointer;
> 
>  begin
> 
>     --create a pointer to the nav to give to the nav interface
>     Pointer_To_Nav := Mynav'Access;  <--- THIS LINE WILL NOT COMPILE
> 
> 
> It tells me that 'Mynav is not accessible from  access all nav'.
> Can someone please help. I have no idea what to do here, or what is causing
> it.


You've fallen victim to the accessibility level problem. Your Navpointer has a 
longer lifetime than your variable Mynav. You could copy Pointer_To_Nav to 
another pointer with longer lifetime than Main, i.e. it would point to an object 
that no longer exists.

That you don't do this here is irrelevant, what matters is lifetime or in RM 
speak accessibility levels.

Use 'Unchecked_Access instead, and you're on yourself to prevent dangling 
pointers.



             reply	other threads:[~2002-03-19 14:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-19 14:45 Christoph Grein [this message]
2002-03-19 19:02 ` Help: Type not accessible Stephen Leake
  -- strict thread matches above, loose matches on Subject: below --
2002-03-20  5:52 Christoph Grein
2002-03-19 13:58 Mattimus
2002-03-19 14:36 ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox