Re: va_lists in glib/gtk and set/get(...) functions



> i'll therefore go through gtk and glib and change the
> void func ([some args], va_list *args1, va_list *args2)
> {
> }
> prototypes to
> void func ([some args], va_list args1)
> {
>   va_list arg2 = args1;
> }

Not so fast... This will not compile if va_list is defined as: 
 typedef char *va_list[0] .

In that case you would have to use the (totally implementation-dependent) 
 char  **arg2 = args1;

But hmm, I'm not 100% sure if that will have the desired effect.
(Well, when I changed gtk like this, at least I don't get the invalid
cast etc warnings any more.)

Maybe it's better to bite the bullet and define some macros, and
document what effect they should product. Something like 

#ifndef __WATCOMC__
#define VA_REF(ap) &ap
#define VA_PTR(ap) *ap
#define VA_PTR_DEREF(ap) (*ap)
#else
#define VA_REF(ap) ap
#define VA_PTR(ap) ap
#define VA_PTR_DEREF(ap) ap
#endif

and modify gtk sources accordingly, ie where now the address of an
va_list is passed to a function, use VA_REF. In a function prototype
that now has va_list *, use VA_PTR, and when using that parameter, use
VA_PTR_DEREF.

This leaves gtk_args_collect where var_args_p comes in as a gpointer,
and is assigned to a va_list *. Here I used the
implementation-dependent hack char **var_args = var_args_p.

--tml



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