Date: Fri, 16 Mar 2001 12:41:02 -0800 From: Brooks Davis <brooks@one-eyed-alien.net> To: j mckitrick <jcm@freebsd-uk.eu.org> Cc: freebsd-chat@FreeBSD.ORG Subject: Re: I mean, rule of THUMB when to use macros Message-ID: <20010316124102.A5637@Odin.AC.HMC.Edu> 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 %2B0000 References: <20010316182415.A33526@dogma.freebsd-uk.eu.org> <20010316105925.C12128@Odin.AC.HMC.Edu> <20010316200628.A34692@dogma.freebsd-uk.eu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010316124102.A5637>