• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSModule question (and partial answer)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSModule question (and partial answer)


  • Subject: NSModule question (and partial answer)
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Mon, 15 Apr 2002 13:38:17 +0200

I would like to gain access to C functions in my own code through their names. I know that it can be done with NSModule, and actually the following example code works:

int doTest2(); // define elsewhere

#include <mach-o/dyld.h>

int doTest() {
NSSymbol symbol;
const char* nom = "_doTest2";
int (*f)();
if (!NSIsSymbolNameDefined(nom)) {
printf("undefined symbol %s", nom);
return -1;
}
symbol = NSLookupAndBindSymbol(nom);
f = NSAddressOfSymbol(symbol);
if (!f) return -2;
return f(); // the function doTest2() is called here
}

Now there are two questions for experts:
1/ Is it possible to retrieve the whole signature of the function by a similar way? (types of arguments, etc.)
2/ I actually need to retrieve symbol in a statically linked library (GSL precisely). But the previous code doesn't work, even when my program is linked with GSL and direct calls to GSL functions work?

Thanks for any help or suggestion,

Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSModule question (and partial answer)
      • From: "Timothy J. Wood" <email@hidden>
  • Prev by Date: (no subject)
  • Next by Date: Documents with multiple windows
  • Previous by thread: Re: Practical deleagte question
  • Next by thread: Re: NSModule question (and partial answer)
  • Index(es):
    • Date
    • Thread