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=0.5 required=5.0 tests=BAYES_00,TO_NO_BRKTS_PCNT, XPRIO autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a0f2b8cad0d0f971,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-26 08:00:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!inf6serv.rug.ac.be!not-for-mail From: "Stijn Rammeloo" Newsgroups: comp.lang.ada Subject: problem with usage of aliased Date: Fri, 26 Oct 2001 16:47:13 +0200 Organization: University of Ghent, Belgium Message-ID: <9rbsln$6m6$1@inf6serv.rug.ac.be> NNTP-Posting-Host: dumbo.rug.ac.be X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: archiver1.google.com comp.lang.ada:15255 Date: 2001-10-26T16:47:13+02:00 List-Id: 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