[fpc-pascal] Converting old pascal written for Pascal/MT+ compiler
Tomas Hajny
XHajT03 at hajny.biz
Tue Mar 28 10:55:38 CEST 2023
On 2023-03-27 11:45, Jacob Kroon via fpc-pascal wrote:
Hi,
> I have some old Pascal code that was compiled in a CPM environment
> using the Pascal/MT+ compiler from Digital Research. I'm trying to get
> this project to build in a modern environment, for a start using
> FreePascal.
>
> First, is anyone aware of a tool for converting this dialect of Pascal
> to something that FreePascal will accept ?
Sorry, no idea.
> Second, the old code contains a lot of:
>
> var
> foobar : external integer;
>
> in sources that reference 'foobar', then there is a declaration in one
> of them:
>
> var
> foobar : integer;
>
> As I understand it, in order to translate this to something that
> FreePascal understands, the variable needs to go in a "unit" and be
> part of its interface. Then, pascal sources that needs to reference
> the variable should use this unit. Is this the easiest way forward ?
Yes, most likely.
> I thought maybe I instead could adapt the syntax like:
>
> var
> foobar : integer; external;
>
> but with this I still get undefined references when linking. Using
> units seems ok.
Indeed - while using the keyword 'external' as outlined in your modified
example would be possible (even for importing a variable from another
FPC compiled unit), it's primary purpose is for importing variables
coming from object files compiled using different compilers (e.g. C,
etc.) and there's no reason for using it for variables declared in a FPC
unit in most cases (let's put some special cases aside for now).
Tomas
More information about the fpc-pascal
mailing list