• 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
__attribute__((used)) not working in Xcode 3?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

__attribute__((used)) not working in Xcode 3?


  • Subject: __attribute__((used)) not working in Xcode 3?
  • From: "B.J. Buchalter" <email@hidden>
  • Date: Thu, 29 Nov 2007 16:28:11 -0500

Hi Folks,

I have some code that utilizes some factory functions at run-time that are not referenced by any code at compile time.

I have dead-stripping enabled, and the linker is striping out these factory functions.

After doing a search in the Xcode docs, I found that I should be able to use a declaration like the following:

extern "C"  MyClass* MyClass_Factory() __attribute__((used));

to mark the function as not-strippable. I have also used __attribute__((visibility("default"))) in both the declaration and definition of the function to ensure that it is externally visible. While the __attribute__((visibility("default"))) does set the proper visibility in the .o file that is generated (verified with nm), the linker still dead-strips the routine out of the final executable.

I have found that if I put the routine in an export list and specify that list to the linker (using the Xcode build settings) that the routine will not be dead stripped. This is a work-around that I could live with if I have to, but it would be much better to be able to specify that the routine should not be dead stripped at the point of declaration so that I don't have to keep the exports file in sync as I add more factories.

This is obviously supposed to work (from the documentation). Any idea of what I am doing wrong here?

TIA,

B.J. Buchalter
Metric Halo
http://www.mhlabs.com
	


_______________________________________________ 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
  • Prev by Date: Re: Xcode 3.0 no longer brings up Debugger window when bp. is hit
  • Next by Date: Property usage warning when targeting 10.4
  • Previous by thread: Re: Xcode 3.0 no longer brings up Debugger window when bp. is hit
  • Next by thread: Property usage warning when targeting 10.4
  • Index(es):
    • Date
    • Thread