Nat! bio photo

Nat!

Senior Mull.

Twitter RSS

Github

deprecation, deprecation, deprecation - Part 1

The initial grievance for this posting is this warning:

foo.m:17: warning: 'NSLookupSymbolInImage' is deprecated 
(declared at /Developer/SDKs/MacOSX10.5.sdk/usr/include/mach-o/dyld.h:182)

When I look into the header I find this:

/*
 * The following dyld API's are deprecated as of Mac OS X 10.5.  They are either  
 * no longer necessary or are superceeded by dlopen and friends in <dlfcn.h>.
 * dlopen/dlsym/dlclose have been available since Mac OS X 10.3 and work with 
 * dylibs and bundles.  
 *
 *    NSAddImage                           -> dlopen
 *    NSLookupSymbolInImage                -> dlsym
 *    NSCreateObjectFileImageFromFile      -> dlopen
 *    NSDestroyObjectFileImage             -> dlclose
 *    NSLinkModule                         -> not needed when dlopen used
 *    NSUnLinkModule                       -> not needed when dlclose used
 *    NSLookupSymbolInModule               -> dlsym
 *    _dyld_image_containing_address       -> dladdr
 *    NSLinkEditError                      -> dlerror
 *
 */

and

extern NSSymbol NSLookupSymbolInModule(NSModule module, const char* symbolName)
AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_5;

So it appeared in 10.1 and it's plug gets pulled in 10.5. Short lived API, I would say.

What bothers me, that one of the ideas behind Foundation is, that it should isolate me from the OS layer and abstract to a common denominator, that remains stable. Yet here, the Foundation functions are deprecated and I am suposed to use dyld directly, although Foundation still could (and probably does) do the work using dyld.

I don't get this.


2 Comments

A photo of Massive Missive

From: Massive Missive

These functions were not part of Foundation, to the best of my knowledge, even though they use the OpenStep name prefix. The NSModule API was only a wafer-thin shim over the Mach-O memory image format, and it was always part of dyld. Support for modern concepts (such as a per-library symbol namespace!) was poor, and the API could never support Apple's or Microsoft's older (in some ways superior) shared libary technologies. dlopen is a standard Unix API far more widely implemented than NSModule.

A photo of Nat!

From: Nat!

Yes. Looking at my code more carefully (inclusion of <mach-o/dyld.h>, I can see that I leapt to the conclusion that NSLookupSymbolInImage was part of Foundation, when it's technically not.


Nevertheless your comment tells me the history of the NSModule API, but still the question remains, was it correct to deprecate it ?


I would assume, that the idea of NS prefixed functions is to abstract and to remain stable. So even if some time in the future dyld dies, I'd expect there would/should be an effort to maintain its semantics. Otherwise why introduce it in the first place ?

Post a comment

All comments are held for moderation; basic HTML formatting accepted.

Name:
E-mail: (not published)
Website: