Sign in Join

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

Mailing lists / fpc-pascal / 2009-07

$IF conditional compilation

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Bee

Hi all,

Say I had a constant declared in a unit...

const
  AValue = true;

In another unit which uses the above unit, I want to have conditional compilation based on the above constant...

{$IF AValue}
   Do something...
{$ELSE}
   Do something else...
{$IFEND}

I know it's possible in Delphi. But, is it possible in FPC? Using the above construct, I always got an 'Internal error 200501152' message. Is it a bug or something?

FYI I'm using FPC v.2.2.5 on Mac. TIA.

-Bee- ...making buzzes at http://twitter.com/beezing ...writing stories at http://beeography.wordpress.com

Reply by email

Jonas Maebe
to Bee
Bee wrote 12 lines
In another unit which uses the above unit, I want to have conditional compilation based on the above constant... {$IF AValue} Do something... {$ELSE} Do something else... {$IFEND} I know it's possible in Delphi. But, is it possible in FPC? Using the above construct, I always got an 'Internal error 200501152' message. Is it a bug or something?

The internal error is due to the fact that your {$if ...} construct appears right after your uses clause: http://bugs.freepascal.org/view.php?id=8611

Jonas

Reply by email

Jonas Maebe
to Bee
Bee wrote 5 lines
> The internal error is due to the fact that your {$if ...} construct > appears > right after your uses clause: http://bugs.freepascal.org/view.php?id=8611 So, it's a bug. Since 2007? :(

Rewriting the unit loading system isn't exactly a trivial task.

Thanks for the hint. I'll find a workaround for that. Any suggestion? TIA.

No idea, sorry. Maybe adding a dummy constant declaration between the uses clause and the {$if ...} expression would help?

Jonas

Reply by email

Bee
to Jonas Maebe
Rewriting the unit loading system isn't exactly a trivial task.

I understand. I just wonder why this bug didn't got priority since it's pretty basic feature for pascal compiler.

No idea, sorry. Maybe adding a dummy constant declaration between the uses clause and the {$if ...} expression would help?

That's what came first to my mind. I'll try it out. TIA.

-Bee- ...making buzzes at http://twitter.com/beezing ...writing stories at http://beeography.wordpress.com

Reply by email

Jonas Maebe
to Bee
Bee wrote
> Rewriting the unit loading system isn't exactly a trivial task. I understand. I just wonder why this bug didn't got priority since it's pretty basic feature for pascal compiler.

You cannot get bugs fixed in a project like FPC by "giving them priority". They only get fixed if someone is interested in fixing them, for whatever reason. Moreover, most of the time the unit loading works fine.

Jonas

Reply by email