tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] error parsing function-pointer type to va_arg


From: Rob
Subject: Re: [Tinycc-devel] error parsing function-pointer type to va_arg
Date: Fri, 29 Jun 2012 21:12:29 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Fri, Jun 29, 2012 at 08:51:42PM +0200, Stephan Beal wrote:
> Hi, all,
>
> from the sqlite4 (yes, 4) sources:
>
>       pMkr->xFactory = va_arg(ap,
>             int(*)(sqlite4_env*, KVStore **, const char *, unsigned int)
>         );
>
> tcc chokes on that with:
>
> ../sqlite4/src/main.c:388: error: ')' expected (got "*")
>
> i'm not clear which "*" it's complaining about, though (i count 5 of them).
>
> Just FYI.

Running through the preprocessor, I get something like:

*(int(*)(int *, int  **, const char *, unsigned int) *) ...

aka:

(int (*f)()) *

The final asterisk added because of a primitive va_arg:

#define va_arg(ap, type) *(type *)(...)
                                ^

However this seems fine by the man page:

> The argument type is a type name specified so that the type of a
> pointer to an object that has the specified type can be obtained
> simply by adding a * to type.

So it's a problem with sqlite4 if you want to be picky.
Looks like gcc and clang tackle this with a builtin va_arg, which I
assume is pushing it a bit for tcc?


If you want a quick fix, something like this will work:

void *tmp = va_arg(ap, void *);
pMkr->xFactory = tmp;


Although the C-standard says that it's implementation defined for converting
between function pointers and non-function pointers.


Cheers,
Rob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]