If you're using C/C++, you can use the cpp macros __FILE__ and __LINE__.  For
example:
     error(0, 0, __FILE__ ":%d: error message", __LINE__);
or
     printf(__FILE__ ":%d: error message\n", __LINE__);

If you're not using C/C++ but still using a build tool (eg make), you can
manually run cpp (if it's available on your system).  If you don't have cpp,
I'll assume you're not running Unix in which case you can download a copy of
CygWin.

Noel





[EMAIL PROTECTED] on 05/28/2000 02:20:15 AM

To:   [EMAIL PROTECTED]
cc:   (bcc: Noel L Yap)
Subject:  Error Messages




The other day I started changing some of my error messages in my app to
use the format mentioned on the GNU coding standards page, i.e.

  filename:linenumber: message

But I soon came to the conclusion that as files got edited this would
cause problems with the line numbers not matching.  I was wondering if
there was anyway that this could be done via cvs via a commit wrapper,
doing a grep -n on one of my source files I get information like:

$ grep -n DebugFmt Main.PAS
545:  DebugFmt('main.pas:542: starting steamfield manager (%s)',

Is there someway I could do something with perl/sed/awk/grep to search for
lines containing "DebugFmt('" and replacing all text upto the first space
with 'filename:linenumber:'?

I know it should be feasible, I'm just not sure how I'd do it, anyone able
to come up with a solution?

Mark







This communication is for informational purposes only.  It is not intended as
an offer or solicitation for the purchase or sale of any financial instrument
or as an official confirmation of any transaction. All market prices, data
and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein
do not necessarily reflect those of J.P. Morgan & Co. Incorporated, its
subsidiaries and affiliates.

Reply via email to