Re: passing args



Eric Monsler wrote:
> 
> D-Man wrote:
> >
> > I like to write functions such as function_prime as a macro because they are so simple.  That way it doesn't take any runtime to call it.
> >
> > -D
> >
> 
> I don't think that the macro approach works when specifying a function
> as a callback.  Does it??  If so, I would love to hear how, because that
> would mean something is seriously broken in my understanding of the
> pre-processor, compilation and linking process and the callback use of
> function pointers.
> 
> I would expect that using:
>   #define function_prime(ARG) function(ARG->arg1,ARG->arg2)
> 
> will cause the line:
>   gtk_timeout_add(interval, function_prime, &data);
> 
> to be expanded to:
>   gtk_timeout_add(interval, function, &data);

not exactly, there will be a compilation error.
because the macro takes at least one argument and no expansion is
possible.

And D-man, macro are not object in memory, it is simply
replacement of text in the source code in the first pass
of the compilation, then it is NOT legal to take the 
address of a macro.

-- 
Hoa




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