Pierre Muller wrote:
It compiles if you put a 'program' statement at the beginning, and change a.check(b) to assign the function result,
I tried this, but here is what I get after your changes: $ gpc test-class-pascal.pas test-class-pascal.pas:4: error: undeclared identifier `class' (first use in this routine) test-class-pascal.pas:4: error: (Each undeclared identifier is reported only once test-class-pascal.pas:4: error: for each routine it appears in.) test-class-pascal.pas:6: error: undeclared identifier `x' (first use in this routine) test-class-pascal.pas:6: error: syntax error before `,'
Pierre@d620-muller ~/pas/test $ gpc --version gpc 20050331, based on gcc-3.4.4 (cygming special, gdc 0.12, using dmd 0.125) Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Is it because I am using version 3.4.4?
gcc version is not a problem. But your gpc is too old: classes are supported starting from gpc-20051104 (the next version after the one you tried).
The problem is that I did not find any system with easy installation of GPC,
AFAICS old Debian binaries should work on new systems. In 2012 Peter Blackman generated Debian/Ubuntu package (IIRC it was at launchpad).
Anyhow, by using objects instead of classes, I was able to compile the modified program, and it turns out that GPC is using 'Self' for the hidden object name for stabs debugging, so that the problem probably does not apply to GPC compiled sources.
Classes are transformed by GPC into pointers to objects, so there is small difference. Attacheched is assembler output from gpc-20070904 using '-fextended-syntax -gstabs -O -S' as options.