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=-1.9 required=5.0 tests=BAYES_00,WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: I do not understand this error... Date: Sun, 7 Feb 2016 09:23:44 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <0528d7a8-773d-44b0-8f0a-e9aa48867443@googlegroups.com> <8778e70b-81e1-4dcc-8ecb-8bcaceb74b57@googlegroups.com> NNTP-Posting-Host: LNA1TkTuMxfwTHzeJdi6nA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:29390 Date: 2016-02-07T09:23:44+01:00 List-Id: On 2016-02-07 01:34, John Smith wrote: > The the following example is wrong: > http://rosettacode.org/wiki/Hello_world/Graphical#Ada > > If so, then how would you fix this? > > On Saturday, February 6, 2016 at 6:47:49 PM UTC-5, Jeffrey R. Carter wrote: >> On 02/06/2016 03:55 PM, John Smith wrote: >>> >>> gtk_test.adb:16:04: instantiation error at gtk-handlers.ads:1039 >>> gtk_test.adb:16:04: subprogram must not be deeper than access type >>> gtk_test.adb:17:04: instantiation error at gtk-handlers.ads:437 >>> gtk_test.adb:17:04: subprogram must not be deeper than access type >> >> This an accessibility check. It means that it's possible for an >> access-to-subprogram value to be copied into a variable which has longer life >> than the subprogram. This is not allowed by the language. Generic packages from Gtk.Handlers cannot be instantiated in the main procedure, due to accessibility check, as Jeffrey wrote. To resolve this move instantiations Handlers and Return_Handles into a separate [library level] package and use this package in the main procedure. In GtkAda contributions there are pre-instantiated handlers to deal with gtk program exit. A working example will look like: -------------------------------------------- with Gtk.Label; use Gtk.Label; with Gtk.Window; use Gtk.Window; with Gtk.Main; with Gtk.Missed; procedure gtk_test is Window : Gtk_Window; Label : Gtk_Label; begin Gtk.Main.Init; Gtk.Window.Gtk_New (Window); Window.On_Delete_Event (Gtk.Missed.Delete_Event_Handler'Access); Window.On_Destroy (Gtk.Missed.Destroy_Handler'Access); Gtk_New (Label, "Goodbye, World!"); Window.Add (Label); Window.Show_All; Gtk.Main.Main; end gtk_test; ----------------------------------------------- http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de