I see how {$ModeSwitch } work now..   I have far more code that only works in 
{$Mode TP} so I supposed I'll have to just re-write things to stay compatible 
with that.   

Is there a {$Modeswitch } feature I can turn on to allow the % to specify 
binary numbers when in {$Mode TP}?    

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Michael 
Van Canneyt
Sent: Monday, July 1, 2019 10:31 AM
To: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
Subject: Re: [fpc-pascal] Changing compiler modes



On Mon, 1 Jul 2019, James Richters wrote:

> I am trying to merge a bunch of my pascal units into a single unit, to avoid 
> circular references.   This is quite a challenge because they are not all 
> compiled with the same mode.
>
> Some units use {$Mode TP} And I can't compile some of the procedures 
> from that unit in other modes because I use features that only work in 
> Turbo Pascal mode, like modifying a for loop variable from inside the 
> loop.  I also have issues with the curly brace { I can't use it as a 
> literal character like MyChar:='{'; because it thinks it's starting 
> comment and it's very strict in not allowing nested comments with 
> curly braces like this Case RunExt of { #134: {F12}
>      Thing1;}
> #3: {Ctrl C}
>       Thing2;
> End;
>
> But then I have other procedures that just won't work in Turbo Pascal mode, 
> because I have used  % to specify binary numbers like this:
> My_Binary_Number := %10011001;  and that just give me an error in Turbo 
> Pascal mode.. I could just change them to hex, but there are hundreds of them.
>
> I'm wondering if there is some way that I can have some procedures compiled 
> with {$Mode FPC} and others with {$Mode TP}
>  I see something about {$ModeSwitch EXCEPTIONS} here: 
> https://wiki.freepascal.org/Compiler_Mode    but I can't get that to work..
>  it doesn't say much about it... If I put that in I still can't change mode 
> for individual procedures.

You can't switch modes between procedure, because a mode implicitly alters the 
uses clause, and for this reason can only occur before the uses clause.

Some mode-specific features can be switched on or off on a per-feature basis, 
but this is not so for all features, and they are also global (i.e.
can be set only once for a unit).

> Alternatively, is there any way to force it to allow circular unit references?

Only from interface to implementation.

If you have such a strange set of units, I would recommend a rewrite in each
case: it doesn't sound like a 'healthy' code base...

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to