Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-04

__LINE__ and __FILE__ macros

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joerg Schuelke

Best regards to all developers,

is it somehow possible to access the line number and file information during the compilation? This would be nice for debugging purposes.

I do not write about the compiled in debug information for gdb.

ASSERT can - i read it in the documentation - access this information.

Is it without to much work possible to make this information accessible as macro?
Are there any plans to extend macro support (parameters?)?

Best regards again

Jörg Schülke

Reply by email

Marco van de Voort
to Joerg Schuelke

In our previous episode, Joerg Schuelke said:

Best regards to all developers, is it somehow possible to access the line number and file information during the compilation? This would be nice for debugging purposes.

Look in the manual under preprocessor $i (include)

Reply by email

Marco van de Voort
to Joerg Schuelke: Am Thu, 28 Apr 2011 18:23:10 +0200 (CEST) schrieb (Marco van de Voort): Thats better…

In our previous episode, Joerg Schuelke said:

Show quoted text 5 lines
> Look in the manual under preprocessor $i (include) > Thats better then nothing, but if you want to include this information in debugging information, and you won't write it again and again you will need an expression which is usable inside an macro.

I use an IDE macro to insert a predefined line, and then I just change the constants I will log. The advantage of that way is that you have full intellisense to specify the vars to dump, something that is always hard with a macro.

Reply by email

Mark Morgan Lloyd
to Joerg Schuelke: Am Thu, 28 Apr 2011 20:09:59 +0200 schrieb Joerg Schuelke : No further explanation…
Joerg Schuelke wrote 5 lines
Am Thu, 28 Apr 2011 20:09:59 +0200 schrieb Joerg Schuelke : No further explanation needed. Nested comments do it. I did not know that {$define mx:= ... (*$%LINE%*)} works.
So that's why (*$define mx:= ... doesn't work :-)
Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Joerg Schuelke
to Marco van de Voort: In our previous episode, Joerg Schuelke said: I use an IDE macro to insert a predefined…

Am Fri, 29 Apr 2011 09:58:08 +0200 (CEST)
schrieb (Marco van de Voort):

I use an IDE macro to insert a predefined line, and then I just change the constants I will log. The advantage of that way is that you have full intellisense to specify the vars to dump, something that is always hard with a macro.

Ok, so far. But: if you write code like

{$define _dp:=writeln(stderr,{$I %FILE%}:20,' [',{$I %LINE%},'] ')}

and somewhere else you use the dp macro, I would expect that it prints out the line number and file name of the place where I used it and not where I defined it. Yesterday I looked in the sources and found that this is because insertmacro is always called with line and file parameters from the defining context.
I think it would be more useful if the {$I %FILE%} and {$I %LINE%} directives expand to the bottom level file name and line number, not the one of the mac.text where they are used and even not from where they may be included.
An other possibility is to make all levels of line and file info accessible trough a construct like {$I %FILE%nnn%}, where nnn% is an optional integer level description.

regards
Jörg

Reply by email