comp.lang.ada
 help / color / mirror / Atom feed
* Ada95 location information
@ 1999-06-14  0:00 dommo1234
  1999-06-15  0:00 ` Stephen Leake
  0 siblings, 1 reply; 2+ messages in thread
From: dommo1234 @ 1999-06-14  0:00 UTC (permalink / raw)


All,

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'm using the Aonix ObjectAda compiler by the way (version 7.1.105,
special edition).

Thanks,
Dom.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Ada95 location information
  1999-06-14  0:00 Ada95 location information dommo1234
@ 1999-06-15  0:00 ` Stephen Leake
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Leake @ 1999-06-15  0:00 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-06-15  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-06-14  0:00 Ada95 location information dommo1234
1999-06-15  0:00 ` Stephen Leake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox