Sign in Join

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

Mailing lists / fpc-devel / 2011-04

{$I %LINE%} and friends

8 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Joerg Schuelke

There is one problem with {$I %LINE%} and his friends, which restricts the use of these directives. They are expanded even inside a macro immediately, so, if you define a macro for debugging purposes, you get the line and file info for the place of the definition and not for the place of the expansion.

I am playing around with the compiler for some weeks, maybe i will send a patch ( in a couple of weeks, the code is somehow complicated ) if desired.

But what is the cleaner way? To defer the expansion of {$I %xxx%} inside macros, or to define c-like macros __LINE__ and __FILE__, maybe with nicer names?

Best regards
Jörg

Reply by email

Unknown author
to Joerg Schuelke
Joerg Schuelke wrote 13 lines
There is one problem with {$I %LINE%} and his friends, which restricts the use of these directives. They are expanded even inside a macro immediately, so, if you define a macro for debugging purposes, you get the line and file info for the place of the definition and not for the place of the expansion. I am playing around with the compiler for some weeks, maybe i will send a patch ( in a couple of weeks, the code is somehow complicated ) if desired. But what is the cleaner way? To defer the expansion of {$I %xxx%} inside macros, or to define c-like macros __LINE__ and __FILE__, maybe with nicer names?

Defer expansion.
The use of {$I } is mandatory, since __LINE__ and friends are valid pascal identifiers and this should not be changed by a macro.

Michael.

Reply by email

Unknown author
to Hans-Peter Diettrich: What about %%LINE%%, or {%LINE%} or {{LINE}}? I wonder why FPC broke Delphi compatibility…
Hans-Peter Diettrich wrote 11 lines
schrieb: >> But what is the cleaner way? To defer the expansion of {$I %xxx%} >> inside macros, or to define c-like macros __LINE__ and __FILE__, maybe >> with nicer names? > > Defer expansion. The use of {$I } is mandatory, since __LINE__ and friends > are valid > pascal identifiers and this should not be changed by a macro. What about %%LINE%%, or {%LINE%} or {{LINE}}?

Keep it simple; the less directives, the better.

I wonder why FPC broke Delphi compatibility by adding {$MODE}, instead of choosing its own prefix for added compiler directives and macros.

Because it would mean yet another kind of directive, this is confusing.

Michael.

Reply by email

Marco van de Voort
to Hans-Peter Diettrich: What about %%LINE%%, or {%LINE%} or {{LINE}}? I wonder why FPC broke Delphi compatibility…

In our previous episode, Hans-Peter Diettrich said:

I wonder why FPC broke Delphi compatibility by adding {$MODE}, instead of choosing its own prefix for added compiler directives and macros.

FPC might not have been that Delphi compatible when this was introduced.

IIRC mode FPC is the oldest, then the mode concept was developed because of some extremely unportable TP features, like the 16-bit array indexing wrap, absolute with 16-bit addresses? Specially the former could also impact performance (inserted instructions on every array access)

Then ObjFPC evolved, and only then Delphi.

In the beginning the idea was to have an totally own oo dialect, but the number of people that worked on it continuously was low and they did burn out fast leaving half finished stuff.

Btw selecting own prefixes is dangerous. Most logical ones have been in use for some external macro or documentation system sooner or later, or some or the other compiler reacts to them. (e.g. & is used by VP iirc)

Reply by email

Hans-Peter Diettrich
to Unknown author: Defer expansion. The use of {$I } is mandatory, since __LINE__ and friends are valid…
Show quoted text 7 lines
> But what is the cleaner way? To defer the expansion of {$I %xxx%} > inside macros, or to define c-like macros __LINE__ and __FILE__, maybe > with nicer names? Defer expansion. The use of {$I } is mandatory, since __LINE__ and friends are valid pascal identifiers and this should not be changed by a macro.

What about %%LINE%%, or {%LINE%} or {{LINE}}?

I wonder why FPC broke Delphi compatibility by adding {$MODE}, instead of choosing its own prefix for added compiler directives and macros.

DoDi

Reply by email

Daniël Mantione
to Unknown author: Keep it simple; the less directives, the better. Because it would mean yet another kind…

Op Fri, 29 Apr 2011, schreef

> I wonder why FPC broke Delphi compatibility by adding {$MODE}, instead of > choosing its own prefix for added compiler directives and macros. Because it would mean yet another kind of directive, this is confusing.

My take on it is that if Delphi aborts on it, that is a Delphi problem. A compiler should warn, not abort, at a unknown directive.

Daniël

Reply by email

Marco van de Voort
to Daniël Mantione

In our previous episode, Dani?l Mantione said:

Show quoted text 7 lines
>> I wonder why FPC broke Delphi compatibility by adding {$MODE}, instead of >> choosing its own prefix for added compiler directives and macros. > > Because it would mean yet another kind of directive, this is confusing. My take on it is that if Delphi aborts on it, that is a Delphi problem. A compiler should warn, not abort, at a unknown directive.

The question is not if that is Delphi's problem, but how you are going to make it their problem and fix it :-)

Reply by email

Florian Klaempfl
to Hans-Peter Diettrich: What about %%LINE%%, or {%LINE%} or {{LINE}}? I wonder why FPC broke Delphi compatibility…
Hans-Peter Diettrich wrote 14 lines
schrieb: >> But what is the cleaner way? To defer the expansion of {$I %xxx%} >> inside macros, or to define c-like macros __LINE__ and __FILE__, maybe >> with nicer names? > > Defer expansion. The use of {$I } is mandatory, since __LINE__ and > friends are valid > pascal identifiers and this should not be changed by a macro. What about %%LINE%%, or {%LINE%} or {{LINE}}? I wonder why FPC broke Delphi compatibility by adding {$MODE}, instead of choosing its own prefix for added compiler directives and macros.

I think an explicit {$ifdef FPC} is much more readable and everybody knows what's meant.

Reply by email