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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a27b8f727dd1e47,start X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!proxad.net!feeder2-1.proxad.net!news9-e.free.fr!not-for-mail From: JCS Subject: GNAT and no runtime Date: Tue, 25 May 2004 22:57:01 +0200 User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity. (Debian GNU/Linux)) Message-Id: Newsgroups: comp.lang.ada MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit Organization: Guest of ProXad - France NNTP-Posting-Date: 25 May 2004 22:57:39 MEST NNTP-Posting-Host: 217.108.166.55 X-Trace: 1085518659 news9-e.free.fr 6333 217.108.166.55:1242 X-Complaints-To: abuse@proxad.net Xref: controlnews3.google.com comp.lang.ada:825 Date: 2004-05-25T22:57:39+02:00 List-Id: Hi, I'm trying to create a toy-OS in Ada and I'm still in the very begining yet. The "kernel" can boot (with the help of GRUB), I can print a "Hello world" text, and retrieve some informations from the bootloader. Before going further, I would like to take advantage of Ada, so at least use exceptions. Obviously, the program can't use the GNAT library, and it is so not linked with it. I also use the pragma No_Runtime, to be sure I'm not using anything which would require the runtime. So then, I enabled the checks, and the linker complained about the missing "__gnat_last_chance_handler" reference. In the GNAT manual, there is a small reference to this function but somewhat unclear in the implementation defined characteristics section: =========================================================== No_Exception_Handlers This restriction ensures at compile time that there are no explicit exception handlers. It also indicates that no exception propagation will be provided. In this mode, exceptions may be raised but will result in an immediate call to the last chance handler, a routine that the user must define with the following profile: procedure Last_Chance_Handler (Source_Location : System.Address; Line : Integer); pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler"); The parameter is a C null-terminated string representing a message to be associated with the exception (typically the source location of the raise statement generated by the compiler). The Line parameter when non-zero represents the line number in the source program where the raise occurs =========================================================== OK, so I made this routine print a litle message and do an endless loop. To test it, I put a "raise Constraint_Error;" in my main routine, obviously without any handler for it. It linked correctly, and it worked, except that Source_Location where pointing to an empty string (but the line was correct). Not so bad, so then I tried to define my own exception, still in my main routine, I wrote sth like: procedure main is ... My_Error : exception; begin ... raise My_Error; end main; But now, it refuses again to link. I got some undefined references, mainly in the elaboration code. It wants to elaborate: Ada.Exceptions System.Exception_Table System.Exceptions System.Soft_Links System.Secondary_Stack And in the main program, I get an undefined reference to Ada.Exceptions.Raise_Exception I'm a bit surprised, why is it so different than with a predefined exception? I didn't think that exceptions need OS-specific functions... Note also: when I use "pragma No_Return(main);", I get a warning with My_Error and not with Constraint_Error: "main.adb:31: attention : `noreturn' function does return" That seems stupid, the function does not return, doesn't it?! So you probably guess my question: is there a solution? Do I have to implement something? Cheers, JC