From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Luke A. Guest" Newsgroups: comp.lang.ada Subject: Re: What does this error mean and how do I correct this? Date: Fri, 1 Sep 2023 22:44:13 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 1 Sep 2023 21:44:13 -0000 (UTC) Injection-Info: dont-email.me; posting-host="071b60dbcff7ef73c47f3433fa26b33f"; logging-data="40653"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ddd133rHo2VTyljlYDlYsOj2efy0lv7A=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Cancel-Lock: sha1:KJH3dXOtQ8qXa3yVERP7FPoS79k= In-Reply-To: Content-Language: en-GB Xref: news.eternal-september.org comp.lang.ada:65581 List-Id: On 01/09/2023 22:41, Luke A. Guest wrote: > Handler needs to be in a package you with. > >> begin  -- Gtk.Init; >>     Gtk.Main.Init; >>     Gtk.Window.Gtk_New (Window => Win, The_Type => >> Gtk.Enums.Window_Toplevel); >>     Win.Set_Position (Win_Pos_Center); >>     Gtk.Window.Set_Title (Window => Win, Title => "Editor"); >>     Gtk.Window.Show_All (Win); >>     Win.On_Button_Press_Event     <------------ line that gets the error >>        (Call =>  Handler'Access, >>         After => False, >>         Slot =>  Win); >>     Gtk.Main.Main; >> end test1; >> >> I get the compiler error message: >> >> test1.adb:32:17: subprogram must not be deeper than access type Ada doesn't like 'access types to be in an area that can go out of scope iirc. You can get around it with unchecked_access, but if you put handler into a package of it's own, it's at library level and is available to grab the access of.