__attribute__((used)) not working in Xcode 3?
__attribute__((used)) not working in Xcode 3?
- Subject: __attribute__((used)) not working in Xcode 3?
- From: "B.J. Buchalter" <email@hidden>
- Date: Sun, 02 Dec 2007 00:12:31 -0500
Bump - surely someone has some idea about this? There is a whole
section in the Xcode docs about this; it seems odd that it would be in
there if it just didn't work at all. I'm hoping the first post went by
and this will catch someone at a better time...
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