comp.lang.ada
 help / color / mirror / Atom feed
From: cosc19z5@Bayou.UH.EDU (Spasmo)
Subject: Gnat3.05 Compile Error Msg
Date: 1996/08/20
Date: 1996-08-20T00:00:00+00:00	[thread overview]
Message-ID: <4vbuvu$jh5@Masala.CC.UH.EDU> (raw)


Hey all.

I'm getting an error message that's baffling me.  Here's what I'm
doing and the error:

I'm trying to return an access to a member of a record via a 
function.  Here's the pertinent code :

	type Int_Ptr is access all Integer;

	type Rec is
		record
			A : String(1 .. 10);
			B : aliased Integer;
		end record;

	function Get_Int_Ptr ( R : in Rec ) return Int_Ptr is
		begin
			return R.B'Access;
		end Get_Int_Ptr;

When I tried compiling this under Gnat3.05 for DOS
the line with the return statement was flagged as an
error and I got the following message:

	"object has deeper accessibility level than access type"

Now I originally assumed it had something to do with returning
a reference out of the context of a certain scope into the
context of a greater scope which made Ada "think" that there
was the possibility of a dangling reference in the works, but
then I tried turning it into a procedure and passing the
"pointer" to it and performing the assignment and I got the
same error.  Does this have something to do with the "pointer"
being embedded in a record?  I vaguely remember doing something
similar, but with a non-aggregate (access X in parameter) and
it worked fine so I'm assuming being in a record incurred
extra complications. 

In any case is there a way I can do what I want to do (return
an access (for aliasing) to a record field)?


Thanks in advance.

--
Spasmo
"Everyone has secrets, but sometimes you get caught,
 So if it's just between us, my silence can be bought"
	"Blackmail" by Sloppy Seconds





             reply	other threads:[~1996-08-20  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-20  0:00 Spasmo [this message]
1996-08-22  0:00 ` Gnat3.05 Compile Error Msg Pascal Ledru
replies disabled

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