From owner-freebsd-chat Fri Mar 16 12:54:17 2001 Delivered-To: freebsd-chat@freebsd.org Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by hub.freebsd.org (Postfix) with ESMTP id F064337B718 for ; Fri, 16 Mar 2001 12:54:13 -0800 (PST) (envelope-from brdavis@odin.ac.hmc.edu) Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.11.0/8.11.0) id f2GKf2r07106; Fri, 16 Mar 2001 12:41:02 -0800 Date: Fri, 16 Mar 2001 12:41:02 -0800 From: Brooks Davis To: j mckitrick Cc: freebsd-chat@FreeBSD.ORG Subject: Re: I mean, rule of THUMB when to use macros Message-ID: <20010316124102.A5637@Odin.AC.HMC.Edu> References: <20010316182415.A33526@dogma.freebsd-uk.eu.org> <20010316105925.C12128@Odin.AC.HMC.Edu> <20010316200628.A34692@dogma.freebsd-uk.eu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="wRRV7LY7NUeQGEoC" Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20010316200628.A34692@dogma.freebsd-uk.eu.org>; from jcm@freebsd-uk.eu.org on Fri, Mar 16, 2001 at 08:06:28PM +0000 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Mar 16, 2001 at 08:06:28PM +0000, j mckitrick wrote: > That's what I'm using them for. Some repeated groups of statements that = are > preambles and cleanups for some function calls. Nothing overly complex, = but > it makes it easier to read. If you mean calling multiple functions with a macro, I can't really recommend that. I'd defiantly consider a function there. Multi-line macros (while somewhat common in the kernel) are generally to be avoided. What I actually meand was things like this: ifmedia_init(&sc->an_ifmedia, 0, an_media_change, an_media_status); #define ADD(m, c) ifmedia_add(&sc->an_ifmedia, (m), (c), NULL) ADD(IFM_MAKEWORD(IFM_IEEE80211, IFM_IEEE80211_DS1, IFM_IEEE80211_ADHOC, 0), 0); [snip another 9 uses of the ADD macro] #undef ADD ifmedia_set(&sc->an_ifmedia, IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, 0, 0)); I got this particular usage from NetBSD and used it in my ifconfig wireless patches. -- Brooks --=20 Any statement of the form "X is the one, true Y" is FALSE. PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4 --wRRV7LY7NUeQGEoC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE6snpdXY6L6fI4GtQRAgFeAJ0TWprf+m1igPJgAYnFRCnv3T2AEACcCIzK vIhNxIkioZN3bT+P5ZMdFeA= =6dEl -----END PGP SIGNATURE----- --wRRV7LY7NUeQGEoC-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message