discuss-gnustep
[Top][All Lists]
Advanced

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

Re: linking tool to use a framework : obj_send_msg error


From: David Chisnall
Subject: Re: linking tool to use a framework : obj_send_msg error
Date: Tue, 14 Apr 2009 15:09:30 +0100

On 13 Apr 2009, at 21:06, Thomas Kupper wrote:

On the other hand, if there are only three calls to objc_msgSend in only one file I could maybe just replace these three calls. But the objc_msg_lookup calls seems to be quite unusal.
With "quite unsual" I mean how can I pass the va_list since the objc_msg_lookup only takes two arguments.

You are only passing two arguments to objc_msg_forward(). You are passing all of the arguments provided to the macro to the function returned by objc_msg_forward(). The __VA_ARGS__ macro is not a va_list, it is a special C99 preprocessor token which is exapended to the arguments passed to the variadic macro.

This call:

objc_msgSend(obj, sel, arg, arg2);

Will, with the macro I gave you, expand to:

objc_msg_lookup(obj, sel)(obj, sel, arg, arg2);

There are some corner cases where this won't work (i.e. if obj or sel is an expression, it will be expanded multiple times - ideally you need to assign these to a temporary variable first, but for most cases the version I gave you should be adequate).

David




reply via email to

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