Sign in Join

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

Mailing lists / fpc-pascal / 2006-09

macros with more than one parameter

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Marc Santhoff

Hi,

how is the correct syntax for macros having more than one parameter?

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

This does not work, even if there is a semicolon between the two parameter names.

Trying to use it like this:

  i := HOFFSET(s1, a); { Line 42 }

The compiler says:

$ 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(42,7) Error: Identifier not found "HOFFSET" offsetof.pas(42,19) Error: Identifier not found "a"

How should this be written?

TIA,
Marc