[fpc-pascal] Changing compiler modes
James Richters
james at productionautomation.net
Mon Jul 1 16:08:30 CEST 2019
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.
Alternatively, is there any way to force it to allow circular unit references? I'm sure there is a technical reason why it's not allowed, but I thought I might as well ask. I have SO MANY duplicate functions because I need them in more than one unit and it's just to prevent creating circular unit references; I'm hoping to avoid a massive re-write to solve all the issues I have with one mode ore the other... that would take years to accomplish.
Any help or suggestions are greatly appreciated.
James
More information about the fpc-pascal
mailing list