comp.lang.ada
 help / color / mirror / Atom feed
From: "Stijn Rammeloo" <stijn.rammeloo@barco.com>
Subject: problem with usage of aliased
Date: Fri, 26 Oct 2001 16:47:13 +0200
Date: 2001-10-26T16:47:13+02:00	[thread overview]
Message-ID: <9rbsln$6m6$1@inf6serv.rug.ac.be> (raw)

Hello,

While writing an interface package for file-manipulation routines I get
following error with gnat: ..."non-local pointer cannot point to local
object."

Gnat flags the code as errornous when I apply the 'Access attribute on the
Current_Part object (which is declared as being alliased). After some
thaught I unserstood why gnat did not liked the code (I'm declaring an
object as being aliased on the stack and pass it on to the Mkdir routine so
there is a potential chance it might get out of scope, when I try to access
it later (or something like that)). However a) I'm passing this as a
parameter to something which is clearly defined as being a function (eg. no
side effects assumed). b) I'm 100% sure I cannot get a dangling pointer. So
my question pops down to this: How can I tell an ada compiler/gnat to stop
nagging in this particular case :-)

   function Mkdir(Char : Interfaces.C.Strings.Chars_Ptr)
     return Interfaces.C.Int;
   pragma Import (Convention => C,
                    Entity => Mkdir,
                    External_Name => "mkdir");

   procedure Try_Create_Next_Missing_Part(Directory: in     Path_Name) is
      Current_Part     : aliased Interfaces.C.Char_Array :=
        Interfaces.C.To_C(To_String(Get_First_Filename_Part(Directory)));
      Remaining_Parts  : Path_Name :=
Get_Remaining_Filename_Part(Directory);

      Status           : Interfaces.C.Int;
   begin

      if not Is_Directory(Directory) then
         Status :=
Mkdir(Interfaces.C.Strings.To_Chars_Ptr(Current_Part'Access));
      end if;

      if Remaining_Parts /= Null_Path_Name then
         Try_Create_Next_Missing_Part(Remaining_Parts);
      end if;
   end Try_Create_Next_Missing_Part;

Thanks in foresee,
Stijn





             reply	other threads:[~2001-10-26 14:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26 14:47 Stijn Rammeloo [this message]
2001-10-26 15:05 ` problem with usage of aliased Ted Dennison
2001-10-27  2:12   ` DuckE
replies disabled

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