Re: Do #pragma weak work in Darwin?
Re: Do #pragma weak work in Darwin?
- Subject: Re: Do #pragma weak work in Darwin?
- From: Paul Nelson <email@hidden>
- Date: Mon, 19 Mar 2007 17:57:54 -0500
- Thread-topic: Do #pragma weak work in Darwin?
The pragma in it's basic form compiles, but does not appear to work.
The pragma in it's alias form gives a warning, and is ignored. I think the
docs only mean to say the pragmas will compile. They don't say the
resulting code will work.
Here is a test sample:
src $ cat weaklink1.c
#include <stdio.h>
#pragma weak testweak
/* #pragma weak testweak = mytestweak */
int mytestweak()
{
return 1;
}
int main( int argc, const char * argv[] )
{
int res = testweak();
printf("testweak() = %d\n", res);
}
src $ cc -g -o testweak weaklink1.c
/usr/bin/ld: Undefined symbols:
_testweak
collect2: ld returned 1 exit status
src $
Also this:
cat weaklink1.c
#include <stdio.h>
#pragma weak testweak = mytestweak
int mytestweak()
{
return 1;
}
int main( int argc, const char * argv[] )
{
int res = testweak();
printf("testweak() = %d\n", res);
}
src $ !cc
cc -g -o testweak weaklink1.c
weaklink1.c:13: warning: alias definitions not supported in Mach-O; ignored
/usr/bin/ld: Undefined symbols:
_testweak
collect2: ld returned 1 exit status
src $
on 3/19/07 4:36 PM, Conrad G T Yoder at email@hidden wrote:
> At 3/19/07 10:39 AM -0500, Paul Nelson <email@hidden> wrote:
>>
>> There are two forms, but both seem to be ignored by GCC:
>>
>> #pragma weak ext_function
>>
>> and
>>
>> #pragma weak ext_function = my_default_ext_function
>> void my_default_ext_function()
>> {
>> }
>
> Information is available in the Xcode documentation.
>
> -Conrad
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden