Sign in Join

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

Mailing lists / fpc-pascal / 2022-04

What's wrong with Leave?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Виктор Матузенко

The test program:

begin
  {$IF Declared(Leave)} Leave; {$ENDIF}
end.

The compilation error:

D:\data\temp>fpc -Mfpc leave_example.pas
Free Pascal Compiler
version 3.2.1 [2021/02/01] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others Target OS: Win32 for i386
Compiling leave_example.pas
leave_example.pas(2,30) Error: Identifier not found "Leave" leave_example.pas(4) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted
Error: D:\prog\FPC\fixes_3_2\bin\i386-Win32\ppc386.exe returned an error exitcode

What's happening?

Victor Matuzenko (Виктор Матузенко)
Jonas Maebe
to Виктор Матузенко
Виктор Матузенко wrote 6 lines
The test program: begin {$IF Declared(Leave)} Leave; {$ENDIF} end.

"Leave" is declared as an intrinsic in the system unit because in MacPas mode it means the same as "break" in UCSD-derivates.

We don't have support in the compiler for declaring intrinsics in units other than the system unit (so we can't declare it in the macpas unit instead), and we don't have a different system unit for each supported syntax mode either (otherwise it would not be possible to mix units compiled in different syntax modes in a single program), which is why you see this behaviour.

Jonsa