Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Feb 2000 11:36:19 +1100
From:      Gregory Bond <gnb@itga.com.au>
To:        Jim Bloom <bloom@acm.org>
Cc:        Kai =?iso-8859-1?Q?Gro=DFjohann?= <Kai.Grossjohann@CS.Uni-Dortmund.DE>, freebsd-current@FreeBSD.ORG, freebsd-ipfw@FreeBSD.ORG
Subject:   Re: cpp change breaks ipfw 
Message-ID:  <200002290036.LAA23453@lightning.itga.com.au>
In-Reply-To: Your message of Mon, 28 Feb 2000 09:18:44 -0500.

next in thread | raw e-mail | index | archive | help
> #define addr 192.186.2.5
> #define mask 255.255.240.0
> =

> #define rule(ADDR,MASK) add pass tcp from ADDR ## : ## MASK to any 25 s=
etup
> rule(addr,mask)

This is a well-known artifact of the ANSI C rules.  You need to do two le=
vels =

of macro in order to get the macro args expanded in the paste operator:

	#define addr 1.2.3.4
	#define mask 255.255.255.0

	#define hn(A,M) A ## : ## M

	#define rule(A,M) add pass tcp from hn(A,M) to any 25 setup

	rule(addr, mask)

which produces
	add pass tcp from   1.2.3.4:255.255.255.0     to any 25 setup =


when fed through an ANSI preprocessor (i.e. not "gcc -E" and not /usr/bin=
/cpp
on 3.x!).  This also works if (e.g.) addr is defined on the command line.=






To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ipfw" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200002290036.LAA23453>