From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/228 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: cluts weekly reports Date: Wed, 3 Aug 2011 13:22:27 -0400 Message-ID: <20110803172227.GX132@brightrain.aerifal.cx> References: <20110803005619.GA2378@openwall.com> <20110803012112.GT132@brightrain.aerifal.cx> <4E3949E3.4090008@gmail.com> <20110803133155.GV132@brightrain.aerifal.cx> <4E398092.8070907@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1312392876 22976 80.91.229.12 (3 Aug 2011 17:34:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 3 Aug 2011 17:34:36 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-312-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 03 19:34:32 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1QofKy-00074c-1n for gllmg-musl@lo.gmane.org; Wed, 03 Aug 2011 19:34:32 +0200 Original-Received: (qmail 14018 invoked by uid 550); 3 Aug 2011 17:34:31 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 14010 invoked from network); 3 Aug 2011 17:34:31 -0000 Content-Disposition: inline In-Reply-To: <4E398092.8070907@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:228 Archived-At: On Wed, Aug 03, 2011 at 07:08:34PM +0200, Luka Marčetić wrote: > > I'm still confused why > >this can't be done in plain C, with the test parameters in C > >structures that you loop over, much like some of the existing tests > >(e.g. numeric). > > It's just a lot of work. The biggest problem C has when applied in > writing unit tests is its inability to use function pointers with > arbitrary number of arguments, and the fact that there's no > (dynamic?) type casting - eg there's no way to pass varying type > arguments to say printf with a correct fmt; once a float, once an > int. Those two make for a load of syntax that like anything but > sugar. That's what I'm trying to generate, instead of having to type > it all. Could you please give some concrete examples of what trouble you're running into? I think you're looking for a very complex solution to a very simple problem, but I can't know until you give me a better idea of the specific problem. There are easy ways to handle this type of thing, with solutions ranging from a macro that concatenates the right type of format specifier into the message string to rolling your own rudimentary message formatting function that takes a void pointer or union type for the data to print. As for function pointers and the need for different numbers and types of arguments, you can either pass a pointer to a structure that contains all of the argument data (thereby always having the same function signature taking a single void * argument) or have a separate type field and cast the function pointer to the right function type and make the call with the right parameters based on the stored type. Rich