mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: cluts weekly reports
Date: Wed, 3 Aug 2011 13:22:27 -0400	[thread overview]
Message-ID: <20110803172227.GX132@brightrain.aerifal.cx> (raw)
In-Reply-To: <4E398092.8070907@gmail.com>

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


  reply	other threads:[~2011-08-03 17:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 17:10 Luka M.
2011-07-25 23:04 ` Luka M.
2011-08-03  0:56   ` Solar Designer
2011-08-03  1:21     ` Rich Felker
2011-08-03 13:15       ` Luka Marčetić
2011-08-03 13:31         ` Rich Felker
2011-08-03 14:51           ` Solar Designer
2011-08-03 17:08           ` Luka Marčetić
2011-08-03 17:22             ` Rich Felker [this message]
2011-08-03 18:03               ` Luka Marčetić
2011-08-03 18:19                 ` Rich Felker
2011-08-03 18:38                   ` Luka Marčetić
2011-08-03 21:59                   ` Luka Marčetić
2011-08-03 22:45                     ` Solar Designer
2011-08-03 22:53                     ` Rich Felker
2011-08-04 11:43                       ` Luka Marčetić

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110803172227.GX132@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).