Declare Lib best practices for library name?

Looking over some code, i see inconsistencies in how Declares are used, e.g.

    declare function objc_getClass lib "/usr/lib/libobjc.A.dylib" ( name as CString ) as integer

and

      declare function objc_getClass lib "/usr/lib/libobjc.dylib" ( name as CString ) as ptr

as well as simply

      declare function objc_getClass lib "libobjc" ( name as CString ) as ptr

any idea which is best?

[quote=94880:@Michael Diehr]Looking over some code, i see inconsistencies in how Declares are used, e.g.

    declare function objc_getClass lib "/usr/lib/libobjc.A.dylib" ( name as CString ) as integer

and

      declare function objc_getClass lib "/usr/lib/libobjc.dylib" ( name as CString ) as ptr

as well as simply

      declare function objc_getClass lib "libobjc" ( name as CString ) as ptr

any idea which is best?[/quote]

Personally, I think the first one is best: your code wants a symbol from that specific version of libobjc, so it should specify that. If you go with the second version, that is what gets embedded into the binary and if that symlink changes to a different version of libobjc, your code could break. In the last case, the compiler has to guess what library you’re after and makes up a path.

Thanks Joe.

And for other declares, such as “Cocoa.Framework” vs “Cocoa” etc, I’m guessing just plain “Cocoa” is the best?

[quote=94891:@Michael Diehr]Thanks Joe.

And for other declares, such as “Cocoa.Framework” vs “Cocoa” etc, I’m guessing just plain “Cocoa” is the best?[/quote]

I would use /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa. Again, you care about that specific version of the library. Plus it avoids running through the compiler’s heuristics.