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.7 required=5.0 tests=BAYES_00,HEADER_SPAM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: ff499,27400c11daf8f7b2 X-Google-Attributes: gidff499,public X-Google-Thread: 103376,27400c11daf8f7b2 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Ada95 location information Date: 1999/06/15 Message-ID: <99-06-067@comp.compilers>#1/1 X-Deja-AN: 490107625 Sender: johnl@iecc.com References: <99-06-064@comp.compilers> X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com Followup-To: comp.lang.ada Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Keywords: Ada Newsgroups: comp.lang.ada,comp.compilers X-FAQ-and-archives: http://www.iecc.com/compilers Date: 1999-06-15T00:00:00+00:00 List-Id: dommo1234@my-deja.com writes: > I'm writing a program in Ada95 and require that when exceptions are > thrown, the location in the source code is included in the message, not > just in the call stack display. I realise there's no pre-processor, but > C and C++ compilers have special tags, eg. "__LINE__", and I wonder > whether Ada compilers have anything silimar. Does anyone know of any > way to obtain this information from the compiler at compile time? I just use Ada.Exceptions.Raise_Exception, and include the full name of the subprogram in the message: package body Foo is procedure Bar is begin if Error then Ada.Exceptions.Raise_Exception (Something_Bad'identity, "Foo.Bar : file not found"); end if; end Bar; end Foo; This is easy to do. Possibly not quite as easy as a preprocessor macro, but typing the subprogram name also makes you think about what else should be in the error message. One problem with this approach is that Ada.Exceptions is _not_ labeled with pragma Preelaborate, so you end up using pragma Elaborate_Body instead, which is not as nice. I hope this will be fixed in an AI soon. -- Stephe