• 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
Weak linked non-functions crashing on check under 10.5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Weak linked non-functions crashing on check under 10.5
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: Re: [Xcode-users] Odd behavior of static objc strings in 10.3
  • Next by Date: Re: Xcode 3.0 and new SCM features
  • Previous by thread: Re: [Xcode-users] Odd behavior of static objc strings in 10.3
  • Next by thread: Re: Weak linked non-functions crashing on check under 10.5
  • Index(es):
    • Date
    • Thread