[fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

Jacob Kroon jacob.kroon at gmail.com
Tue Apr 4 09:38:11 CEST 2023

Hi Bernd,

On 4/4/23 08:54, Bernd Oppolzer via fpc-pascal wrote:
> Am 04.04.2023 um 08:16 schrieb Jacob Kroon via fpc-pascal:
>> Thanks for the tip above.
>> I was able to write a couple of perl-scripts that are able to convert 
>> my old Pascal sources to something that fpc can parse. Amongst other 
>> things, the scripts inject the "public name"/"external name" 
>> annotations so that the program can link.
>> But I suspect I have a new problem: With the old Pascal/MT+ compiler 
>> it would appear that local variables declared in functions/procedures 
>> have a life-time that spans the whole program, like a "static" 
>> declared variable in C. With fpc, it looks like locally declared 
>> variables are automatic, put on the stack(?), and so they go out of 
>> existence once out of scope ?
> IMO, this is not a feature of the old PASCAL compiler,
> but instead your Pascal programs "by error" depends on the local variables
> appearing at the same location on the stack at subsequent calls as before
> (if there are no other calls at the same level in between).

There is a programmers guide for the Pascal/MT+ compiler here:


In chapter 4.1 it states that the "LOCAL VARIABLE STACK" is only used in 
programs compiled with the $S+ option set for recursion, and I don't see 
it set anywhere in my source code. So I think in my case, the local 
variables are actually not stored on the stack.



More information about the fpc-pascal mailing list