Hi,

the docs only show examples of macros without any parameters. Is it
possible to use them?

Can I make this work anyhow:

{$MACRO ON}
{$define HOFFSET(rec,field) := pointer(@rec.field) - pointer(@rec)}

type
        s1_t = record
                a: longint;
                b: single;
                c: double;
        end;
var
        s1: s1_t;
BEGIN
        s1.a := 12345;
        s1.b := 1.000000001;
        s1.c := 1.000000002;

        writeln(HOFFSET(s1, a)); { Line 32 in my code }
END.

Written as it is the compiler doesn't like it:

$ fpc offsetof
Free Pascal Compiler version 2.0.2 [2005/11/17] for i386
Copyright (c) 1993-2005 by Florian Klaempfl
Target OS: FreeBSD/ELF for i386
Compiling offsetof.pas
offsetof.pas(32,10) Error: Identifier not found "HOFFSET"
offsetof.pas(32,22) Error: Identifier not found "a"
offsetof.pas(32,25) Error: Illegal expression

Other solutions are very welcome...

TIA,
Marc


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to