I've got a few thousand lines of Pascal which I'm converting to FPC. It's actually the Meta-2 compiler-compiler which despite its age I still find useful for embedded script processing, I hope eventually to get it running on SPARC and possibly ARM as well as x86. Linux will not be the first OS this code has run on, by any means.

This code was originally written using MT+86, but compatibility with that has been sacrificed and it now works with TopSpeed Pascal, TP5.5 and Delphi. Because it is still compilable with TopSpeed which doesn't use the "standard" directive and conditional-compilation format I'm having to be very careful with the source.

In one place I am checking a number of procedure variables which are actually callbacks for reading input etc., if they're NIL then default procedures are used instead. For portability I have defined myself a function

FUNCTION AddressOf(VAR x): POINTER;

Hence

IF AddressOf(source) <> NIL THEN
  state.source:= source
ELSE
  state.source:= dummyRead;

That works OK with the other compilers but when compiling with FPC it reports "Wrong number of parameters specified for call to "<Procedure Variable>".

If instead I use

IF @source <> NIL THEN
  state.source:= source
ELSE
  state.source:= dummyRead;

that works with FPC and probably other Borland-style compilers, but not with TopSpeed.

Is there a directive or mode that will allow a procedure variable to be compatible with AddressOf() as defined? Alternatively is there a type which is compatible with any procedure variable (i.e. like Modula-2's PROC, if my memory is correct), and can I overload AddressOf() to handle the specific case of a procedure passed as parameter while leaving it tolerant of other types?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to