Sign in Join

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

Mailing lists / fpc-devel / 2011-05

Macro Patch

3 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

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

Joerg Schuelke

Some days ago I stated that the build-in macros %LINE% and %FILE%, used inside a macro, expand to the wrong (in my opinion) info from the defining context and not to those from the expanding context.

That makes them nearly useless, because using them inside a macro for debugging purposes is their main benefit.

I wrote two small changes for scanner.pas and fmodule.pas which solve the problem. Maybe the devils are interested in applying it, or something similar.

The 'unknown' from my changes are in real Internal-Errors, which should never occur. But changing this let's trying him to find an Environment- Variable with the same name, which gives a Warning. So ...

Best regards
Jörg

Reply by email

Joerg Schuelke

A little further changing is needed to let it work as suspected. Even if the macro is included via include file. In my first writing I didn't recognize that the calling of insertmacro for _ID token is done with mac.fileinfo.line and .fileindex, which is the point of definition.

Changed to current_scanner.line_no and
current_scanner.inputfile.ref_index.

Is this a problem for error recognition?, I think not, because the info from the defining context is saved in the tmacro class.

Best regards
Jörg

Reply by email