From owner-freebsd-questions@FreeBSD.ORG Sun May 4 15:47:37 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28082106564A for ; Sun, 4 May 2008 15:47:37 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr12.xs4all.nl (smtp-vbr12.xs4all.nl [194.109.24.32]) by mx1.freebsd.org (Postfix) with ESMTP id C4F6C8FC22 for ; Sun, 4 May 2008 15:47:36 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr12.xs4all.nl (8.13.8/8.13.8) with ESMTP id m44FlYkY049106; Sun, 4 May 2008 17:47:35 +0200 (CEST) (envelope-from rsmith@xs4all.nl) Received: by slackbox.xs4all.nl (Postfix, from userid 1001) id 4D64DB844; Sun, 4 May 2008 17:47:34 +0200 (CEST) Date: Sun, 4 May 2008 17:47:34 +0200 From: Roland Smith To: Unga Message-ID: <20080504154734.GA98310@slackbox.xs4all.nl> Mail-Followup-To: Unga , Patrick Clochesy , freebsd-questions@freebsd.org References: <20080504144532.GA56965@slackbox.xs4all.nl> <630200.71551.qm@web57011.mail.re3.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline In-Reply-To: <630200.71551.qm@web57011.mail.re3.yahoo.com> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.17 (2007-11-01) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: Patrick Clochesy , freebsd-questions@freebsd.org Subject: Re: Variable arg function question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 May 2008 15:47:37 -0000 --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 04, 2008 at 08:34:30AM -0700, Unga wrote: >=20 > --- Roland Smith wrote: >=20 > > On Sun, May 04, 2008 at 07:02:36AM -0700, Patrick > > Clochesy wrote: > > > What about using a macro (...) in front of the > > function to csll it which=20 > > > passes __VARARGS__, NULL to ensure there is always > > a trailing NULL? I think=20 > > > this would at least work in GCC... Can' test on my > > phone though. > >=20 > > That's a good idea. If one uses __VA_ARGS__ instead > > of __VARARGS__, it > > should work with any C99 compliant compiler, > > including gcc. > I gave it a try, but I cannot get it to work: > (As per above wikipedia example) >=20 > void realdprintf (char const *file, int line, char > const *fmt, ...);=20 > #define dprintf(...) realdprintf(__FILE__, __LINE__, > __VA_ARGS__) >=20 > To solve my problem, I must be able to indicate the > end of the arg list, may be by a empty string (""), > but GNU C compiler does not allow to specify anything > after the ... . Try something like what Patrick suggested: #define f(...) _f(__VA_ARGS__,NULL) Roland --=20 R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --HcAYCG3uE/tztfnV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkgd2pYACgkQEnfvsMMhpyVRkwCfcybIIXDxyps4+w2IRwMXIXBJ tcYAn18HLVbznyHhtWSrOKWLNIfXlXyX =hYUe -----END PGP SIGNATURE----- --HcAYCG3uE/tztfnV--