site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Thread-index: AcdqNGKxoX2MftYnEdui4gAWy4i6sAAOjNhMAALcPvw= Thread-topic: Do #pragma weak work in Darwin? User-agent: Microsoft-Entourage/11.3.3.061214 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 conrad@yoders.org wrote:
At 3/19/07 10:39 AM -0500, Paul Nelson <nelson@thursby.com> 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com