Re: Executing non objective-c code in a loaded bundle
Re: Executing non objective-c code in a loaded bundle
- Subject: Re: Executing non objective-c code in a loaded bundle
- From: Chris Suter <email@hidden>
- Date: Wed, 28 Jun 2006 15:50:05 +1000
On 28/06/2006, at 3:35 PM, Damien Sorresso wrote:
On 27 Jun, 2006, at 11:41 PM, Mark Williams wrote:
I have a bundle with a couple of plain old C functions in it. When
I load it I have no trouble executing any objective-c code but I
do not know how to execute a regular c function from the loaded
bundle like somefunction(); Is it possible to do this or do I have
to convert it all to obj-c?
It sounds like you probably have your C functions declared inside
@interface
.
.
.
@end
Move their declarations outside of the `@interface ... @end'
context, and you'll be able to call them from `main()' or wherever.
You'll also still be able to call them from within the class. Also
move the method definitions outside of the `@implementation ...
@end' context in your implementation file.
This isn't really the problem.
The problem is getting the symbols linked. If the bundle is loaded by
the dynamic linker (as a framework) then this would work fine.
However if you're loading it at runtime (which is what I believe is
happening here), it's a bit more tricky. It's still possible to have
stuff linked later when it's loaded at runtime but you have to link
with -flat_namespace and use the -U linker flag (I think).
If you're not worried about duplicate symbols, you don't need to use
CFBundle. You can just use dlsym or I think there's an NSModule
equivalent. There might be issues with this if running earlier than
10.3 (I'm not sure).
- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden