Related articles |
---|
Ada95 location information dommo1234@my-deja.com (1999-06-14) |
Re: Ada95 location information Stephen.Leake@gsfc.nasa.gov (Stephen Leake) (1999-06-15) |
From: | Stephen Leake <Stephen.Leake@gsfc.nasa.gov> |
Newsgroups: | comp.lang.ada,comp.compilers |
Followup-To: | comp.lang.ada |
Date: | 15 Jun 1999 23:47:04 -0400 |
Organization: | NASA Goddard Space Flight Center -- Greenbelt, Maryland USA |
References: | 99-06-064 |
Keywords: | Ada |
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
Return to the
comp.compilers page.
Search the
comp.compilers archives again.