Weak linked non-functions crashing on check under 10.5
Weak linked non-functions crashing on check under 10.5
- Subject: Weak linked non-functions crashing on check under 10.5
- From: Rosyna <email@hidden>
- Date: Thu, 10 Jan 2008 09:19:22 -0700
I'm trying to weak link to some symbols to ensure backwards
compatibility going into the future (say, with MDItem.h, for example).
But when I try to weak link something that is *not* a function, the
application crashes on 10.5 if the symbol doesn't exist, even when I
test for the symbol.
Below is a short example showing this. Do I do something wrong? I've
weak linked non-function symbols (from MDItem.h, when they have the
symbols have the *correct* linker attributes...) without issue on 10.4
and 10.3. (I am compiling this on 10.5).
(Of course, I'd never, ever, ever try to do this with kCTStyleNameKey,
it was just a symbol (exported CFStringRef) I happened to see exists
on 10.4 but doesn't on 10.5... It's just an example... I swear...)
Example (Into weaktest.c):
#include <CoreFoundation/CoreFoundation.h>
extern CFStringRef kCTStyleNameKey WEAK_IMPORT_ATTRIBUTE;
int main(int argc, char* argv[])
{
printf("Hi there!\n");
if (kCTStyleNameKey!=NULL)
printf("kCTStyleNameKey is: %p\n", kCTStyleNameKey);
printf("Printed the something!\n");
return 0;
}
Compile:
cc -framework Carbon -framework CoreFoundation -isysroot /Developer/
SDKs/MacOSX10.4u.sdk -o linktest ./weaktest.c
Run:
./linktest
Output:
Hi there!
Bus error
Confirming it is indeed weak linked:
nm -mg ./linktest | grep weak
(undefined) weak external _kCTStyleNameKey (from ApplicationServices)
Line it crashes on:
if (kCTStyleNameKey!=NULL)
---
Sincerely,
Rosyna Keller
Technical Support/Carbon troll/Always needs a hug
Unsanity: Unsane Tools for Insanely Great People
It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden