Re: passing args



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);

and, when called, to have the effect of calling
  function( ((type1 *)&data), ((type2 *)rand()) );

Where rand() is not really called of course, but represents some unknown
content of a register or stack location used to pass the second argument
of a function, when the call by pointer expects to be passing one
argument.


Eric




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