Re: linking tool to use a framework : obj_send_msg error
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 ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
В Sun, 12 Apr 2009 23:23:13 +0200, Thomas Kupper написа: Can someone give me a hint how I can track down that error? Use ADDITIONAL_TOOL_LIBS, e.g. ADDITIONAL_TOOL_LIBS = -llog4cocoa ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
On 12 Apr 2009, at 22:23, Thomas Kupper wrote: Next I created a very minimalistic tool application which uses the log4cocoa framework (of course I first installed it into the USER domain). Now the linker throws an error message Linking tool ocHello ... /home/thomas/GNUstep/Library/Libraries/liblog4cocoa.so: undefined reference to 'objc_msgSend'. collect2: ld returned 1 exit status There is probably some 'optimisation' in the framework calling the Apple runtime message send function directly (the quotes because anything doing I/O like this is likely to gain an imperceptible performance increase from calling the runtime functions directly rather than using -methodForSelector:). Try grepping the source code for objc_msgSend() and, in files that contain it, add this macro: #define objc_msgSend(theReceiver, theSelector, ...) \ objc_msg_lookup(theReceiver, theSelector)(theReceiver, theSelector, ## __VA_LIST__) How can that happen if the framework compiles/links fine. And the tool compiles/links fine, too without using the framework. Libraries are not checked for unresolved symbols when they are linked. This allows you to create a library which depends on a function that is declared in an application, providing a fast (although very fragile, unsafe, and stupid) way of implementing callbacks, but is mainly intended for static libraries which are intended to be combined with others to provide a full implementation of an API. Can someone give me a hint how I can track down that error? Look for objc_msgSend() in the log4cocoa framework source. David ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
There is probably some 'optimisation' in the framework calling the Apple runtime message send function directly (the quotes because anything doing I/O like this is likely to gain an imperceptible performance increase from calling the runtime functions directly rather than using -methodForSelector:). Try grepping the source code for objc_msgSend() and, in files that contain it, add this macro: #define objc_msgSend(theReceiver, theSelector, ...) \ objc_msg_lookup(theReceiver, theSelector)(theReceiver, theSelector, ## __VA_LIST__) Perfect! That's exactly what causes the error. In one file there are three calls to objc_msgSend. Now I tried to define the macro you mentioned. Unfortunately the # __VA_LIST__ part is not recognized and Google wasn't any help, and neither was a find ... -exec fgrep 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. Would you mind helping my again? I tried to compile it under Ubuntu 8.10/Debian 5.0. Thanks for excellent help! Thomas ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
On 13 Apr 2009, at 20:49, Thomas Kupper wrote: There is probably some 'optimisation' in the framework calling the Apple runtime message send function directly (the quotes because anything doing I/O like this is likely to gain an imperceptible performance increase from calling the runtime functions directly rather than using -methodForSelector:). Try grepping the source code for objc_msgSend() and, in files that contain it, add this macro: #define objc_msgSend(theReceiver, theSelector, ...) \ objc_msg_lookup(theReceiver, theSelector)(theReceiver, theSelector, ## __VA_LIST__) Perfect! That's exactly what causes the error. In one file there are three calls to objc_msgSend. Now I tried to define the macro you mentioned. Unfortunately the # __VA_LIST__ part is not recognized and Google wasn't any help, and neither was a find ... -exec fgrep Sounds like you have your compiler set to use some archaic dialect of C. Add -std=c99 to your CFLAGS. 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. You can do that too, just expand the macro, so: objc_msgSend(obj, sel, args); becomes: objc_msg_lookup(obj, sel)(obj, sel, args); (objc_msg_lookup() returns a pointer to the function that you call. objc_msgSend() does the lookup and the call as a single operation in the Mac runtime). David ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
Hey David, I already set -std=c99 in GNUmake.preamble. Tried both ADDITIONAL_CFLAGS and .._OBJCFLAGS but in both cases the __VA_LIST_ macro isn't defined. Mmmh, I use gcc 4.3. Do you have any other idea? Thomas On 13 Apr 2009, at 22:11, David Chisnall wrote: On 13 Apr 2009, at 20:49, Thomas Kupper wrote: There is probably some 'optimisation' in the framework calling the Apple runtime message send function directly (the quotes because anything doing I/O like this is likely to gain an imperceptible performance increase from calling the runtime functions directly rather than using -methodForSelector:). Try grepping the source code for objc_msgSend() and, in files that contain it, add this macro: #define objc_msgSend(theReceiver, theSelector, ...) \ objc_msg_lookup(theReceiver, theSelector)(theReceiver, theSelector, ## __VA_LIST__) Perfect! That's exactly what causes the error. In one file there are three calls to objc_msgSend. Now I tried to define the macro you mentioned. Unfortunately the # __VA_LIST__ part is not recognized and Google wasn't any help, and neither was a find ... - exec fgrep Sounds like you have your compiler set to use some archaic dialect of C. Add -std=c99 to your CFLAGS. 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. You can do that too, just expand the macro, so: objc_msgSend(obj, sel, args); becomes: objc_msg_lookup(obj, sel)(obj, sel, args); (objc_msg_lookup() returns a pointer to the function that you call. objc_msgSend() does the lookup and the call as a single operation in the Mac runtime). David ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
On 13 Apr 2009, at 21:43, Thomas Kupper wrote: Hey David, I already set -std=c99 in GNUmake.preamble. Tried both ADDITIONAL_CFLAGS and .._OBJCFLAGS but in both cases the __VA_LIST_ macro isn't defined. Mmmh, I use gcc 4.3. Do you have any other idea? Yes - you ignore what I say, for I am talking nonsense. Sorry, that should be __VA_ARGS__, not __VA_LIST__. In full: #define objc_msgSend(obj, sel, ...) \ objc_msg_lookup(obj, sel)(obj, sel, ## __VA_ARGS__) David ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep
Re: linking tool to use a framework : obj_send_msg error
You're my hero! I ignored what you said first and did what you said second and it compiles/links like a charm!! Thanks alot Thomas On 13 Apr 2009, at 23:07, David Chisnall wrote: On 13 Apr 2009, at 21:43, Thomas Kupper wrote: Hey David, I already set -std=c99 in GNUmake.preamble. Tried both ADDITIONAL_CFLAGS and .._OBJCFLAGS but in both cases the __VA_LIST_ macro isn't defined. Mmmh, I use gcc 4.3. Do you have any other idea? Yes - you ignore what I say, for I am talking nonsense. Sorry, that should be __VA_ARGS__, not __VA_LIST__. In full: #define objc_msgSend(obj, sel, ...) \ objc_msg_lookup(obj, sel)(obj, sel, ## __VA_ARGS__) David ___ Discuss-gnustep mailing list Discuss-gnustep@gnu.org http://lists.gnu.org/mailman/listinfo/discuss-gnustep