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

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


  • Subject: Re: __attribute__((used)) not working in Xcode 3?
  • From: "B.J. Buchalter" <email@hidden>
  • Date: Sun, 02 Dec 2007 02:32:19 -0500

Hi Peter,


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


Thanks for the response and confirmation.

I did some more google searching, and while this is not well documented elsewhere, there are a number of examples of its use in open-source linux code.

I think that it is that the (apple) documentation is wrong (I have now filed documentation feedback).

For the list archive here is the actual behavior:

void func(void)  __attribute__((used));
void func(void) {}

is accepted, but does not work.

 __attribute__((used)) void func(void);
void func(void) {}

is also accepted, but does not work.

void func(void);
void func(void)  __attribute__((used)) {}

is not accepted; it causes a compile time error.

void func(void);
 __attribute__((used)) void func(void) {}

is accepted, and does work (the function is actually marked with no_dead_strip).

So I am not clear that this is a bug in the compiler, as some combination does work.

It does seem to be a compiler bug that it does accept the attribute without generating at least a warning that the attribute will have no effect.

It is definitely a documentation bug that the docs suggest doing something that does not work (and I have filed feedback on that).

So to summarize, if you want to use the attribute to mark a routine as not strippable, put the attribute before the function signature in the definition (not the declaration) of the function.


It appears to be broken, file a bug.

The asm output I see with __attribute__((used)) and without for this:

void i(int*) __attribute__((used));
/* asm(".no_dead_strip _i"); */
void i (int *a) {
if (a) *a = *a + 5;
}

int main() { return 0;}

is identical.

If you really want -dead_strip to not strip the function in Xcode-3.0
use the .no_dead_strip asm directive (which gcc should be inserting with
__attribute__((used)), but does not appear to be doing.


Peter
--
Peter O'Gorman
http://pogma.com

Best regards,

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
  • Follow-Ups:
    • Re: __attribute__((used)) not working in Xcode 3?
      • From: Peter O'Gorman <email@hidden>
References: 
 >__attribute__((used)) not working in Xcode 3? (From: "B.J. Buchalter" <email@hidden>)
 >Re: __attribute__((used)) not working in Xcode 3? (From: Peter O'Gorman <email@hidden>)

  • Prev by Date: Re: __attribute__((used)) not working in Xcode 3?
  • Next by Date: Re: __attribute__((used)) not working in Xcode 3?
  • Previous by thread: Re: __attribute__((used)) not working in Xcode 3?
  • Next by thread: Re: __attribute__((used)) not working in Xcode 3?
  • Index(es):
    • Date
    • Thread