Re: Ada95 location information

Stephen Leake <>
15 Jun 1999 23:47:04 -0400

          From comp.compilers

Related articles
Ada95 location information (1999-06-14)
Re: Ada95 location information (Stephen Leake) (1999-06-15)
| List of all articles for this month |

From: Stephen Leake <>
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 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
            if Error then
                          "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

-- Stephe

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.