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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c6546cb6e04b1761 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: __FILE__ and __LINE__ Date: 1997/04/07 Message-ID: <01bc434e$d36430c0$298c71a5@dhoossr.iquest.com>#1/1 X-Deja-AN: 231281150 Distribution: world References: <5ia77f$go3@nlrgup.nlr.nl> Organization: Ada95 Press, Inc. Newsgroups: comp.lang.ada Date: 1997-04-07T00:00:00+00:00 List-Id: Hi Carl, Although to my knowledge gnat does not do exactly what you're describing, it does do what is needed for one of the mist frequent uses of __FILE__ and __LINE__, i.e., identify the source code location of failed assertions. The source code which follows gives an example of what can be done. Two pragmas, Debug and Assert are enabled by the -gnata compiler switch. The Assert pragma causes the raising of an exception at the point of a failed assertion. The exception is raised with an exception message consisting of the file name, followed by a colon, followed by the line number. The Ada95 exception occurrence facilities permit extraction of the exception message in the exception handler. The contrived example illustrates the features: ---- begin example source code ----------------- with Ada.Exceptions; with Ada.Text_IO; with System.Assertions; procedure Assert is begin pragma Debug (Ada.Text_IO.Put_Line ("Debug message")); Ada.Text_IO.Put_Line ("About to make false assertion"); begin pragma Assert (False); null; exception when E: System.Assertions.Assert_Failure => Ada.Text_IO.Put_Line ("Assertion at " & Ada.Exceptions.Exception_Message (E) & " failed."); end; Ada.Text_IO.Put_Line ("After false assertion handled"); end Assert; ---- end example source code ---------- -- David C. Hoos, Sr., http://www.dbhwww.com http://www.ada95.com Carl G.M. Welman wrote in article <5ia77f$go3@nlrgup.nlr.nl>... > Dear all, > > I am looking for Ada equivalents for the C preprocessor macros > "__FILE__" and "__LINE__", which result in the source file name > (constant string) and the line number (integer) of the file/position > they are specified, respectively. As far as I know there are no > pragma's in Ada 95 or GNAT 3.x that do similar things. Maybe there are > other means to do the same ? Or is this impossible in Ada 95 ? > > Regards, Carl. >