From owner-freebsd-questions@FreeBSD.ORG Sun May 4 14:02:50 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 AC3C31065673 for ; Sun, 4 May 2008 14:02:50 +0000 (UTC) (envelope-from pcloches@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.235]) by mx1.freebsd.org (Postfix) with ESMTP id 90C398FC1B for ; Sun, 4 May 2008 14:02:50 +0000 (UTC) (envelope-from pcloches@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so1719754rvf.43 for ; Sun, 04 May 2008 07:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:references:message-id:from:to:in-reply-to:content-type:x-mailer:mime-version:subject:content-transfer-encoding:date:cc; bh=RGj8kWbopYhsXLt4NqMyy5LooNHahGme+rtFDo/zuFk=; b=PchzztvlHKqSh12i0dQJ07/lQCb/R78rwxlilOFMadbbBmYmXcmr9Lgonnr6T81TYj48/OrVBVIwxjbtx2LIBY+2FK3HsKSRvoqqZ+5cqrlP56yyklOK92CvCeQpsNO6bN/d0PBuuCJSMoLN9MH7vFnSDCOecLoj6JT6gZSe5Pc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=references:message-id:from:to:in-reply-to:content-type:x-mailer:mime-version:subject:content-transfer-encoding:date:cc; b=cvnh23kH0puKuBoB6GvAFLpJ5yuePWjHhajj/t5gj7dhk9Fnt/YmEChCCYWllH0MnyEf3y1RQqhaozIchp4vQaiHsgzIL5iCaYRz6vA7E15fNN7y6PbkUdNmeXoY7hUs4K3egBL9+o2oiAcXrQRruGccA4oLKTHuw/povQBzeZU= Received: by 10.140.134.15 with SMTP id h15mr2323871rvd.48.1209909770192; Sun, 04 May 2008 07:02:50 -0700 (PDT) Received: from ?10.94.103.37? ( [32.158.50.16]) by mx.google.com with ESMTPS id f42sm7196592rvb.5.2008.05.04.07.02.46 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 04 May 2008 07:02:49 -0700 (PDT) References: <336540.36159.qm@web57014.mail.re3.yahoo.com> <481DA10B.30903@boosten.org> Message-Id: <8FF3737F-1292-4A19-8A7D-789D8DD70CBE@gmail.com> From: Patrick Clochesy To: Peter Boosten In-Reply-To: <481DA10B.30903@boosten.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes X-Mailer: iPhone Mail (4A102) Mime-Version: 1.0 (iPhone Mail 4A102) Content-Transfer-Encoding: 7bit Date: Sun, 4 May 2008 07:02:36 -0700 Cc: Unga , "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 14:02:50 -0000 What about using a macro (...) in front of the function to csll it which passes __VARARGS__, NULL to ensure there is always a trailing NULL? I think this would at least work in GCC... Can' test on my phone though. -Patrick On May 4, 2008, at 4:42 AM, Peter Boosten wrote: > Unga wrote: >> Hi all >> I need to implement a variable argument function in C. >> The number of args are not known but the type is >> known, all are strings. >> Unfortunately va_arg() [stdarg(3)] does not return >> NULL or any other suitable value after processing the >> arg list, it just simply crashes once the arg list is >> exhausted. >> It seems there is no way to know the number of args >> inside the called function. > > Why is it in your opinion so hard to count the number of arguments > *before* you call the function, in other words, what in your program > prevents this count? > > Peter > -- > http://www.boosten.org > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org > "