|
Message-ID: <20110803172227.GX132@brightrain.aerifal.cx> Date: Wed, 3 Aug 2011 13:22:27 -0400 From: Rich Felker <dalias@...ifal.cx> To: musl@...ts.openwall.com Subject: Re: cluts weekly reports 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
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.