Getting line number where error occured?

Bill Baxter wbaxter at gmail.com
Wed Jan 14 19:09:33 PST 2009


On Thu, Jan 15, 2009 at 12:02 PM, Sergey Gromov <snake.scaly at gmail.com> wrote:
> Thu, 15 Jan 2009 02:47:07 +0100, Hoenir wrote:
>
>> Might be a dumb question, but is it possible in any way to get the line
>> number where an error occured?
>> Don't think so, but maybe I'm missing something.
>
> assert gives a line number.  There's also a keyword, __LINE__, which is
> an expression evaluating to the current line number, like in
>
> writefln(__LINE__);
>
> If you mean an exception stack trace then no, there's no such thing,
> though it's a very popular feature request.

Nothing built-in for this,
but there are the backtrace hacks: http://team0xf.com/index.php?n=Site.Download
Never tried those myself though.

I use a debugger when I need a stack trace.
http://ddbg.mainia.de/releases.html (Windows - on Linux I think you
can use GDB).

--bb


More information about the Digitalmars-d-learn mailing list