Hi Dave, Dave Korn wrote: > >> These were all due to the fact that gcc 4.3.x on Cygwin 1.7.2 > >> accepts "#pragma weak foo", but the symbol foo then evaluates > >> to the NULL address, even if foo is defined in libc. > > > > Dave, are weak symbols something that should work on cygwin with new > > enough binutils/gcc? Or is this an indicator of a gcc bug, for silently > > accepting #pragma weak foo that it can't support? > > Weak symbols work on Cygwin, but the semantics of undefined weak symbols > aren't identical to ELF platforms: a weak reference won't pull in an archive > member that wouldn't otherwise be linked; the implications in relation to > import libraries should be fairly obvious.
I don't know what semantics is implemented by "#pragma weak" on Cygwin. On ELF platforms, I use "#pragma weak" in order to detect whether a symbol is defined in the libraries which are linked in with the executable (including libc). This does not work on Cygwin: this program ====================================================== #include <stdio.h> extern void gurky (void); #pragma weak fputs #pragma weak gurky int main () { printf ("fputs %s, gurky %s\n", fputs != NULL ? "present" : "missing", gurky != NULL ? "present" : "missing"); return 0; } ====================================================== compiled and run with $ gcc -o foo foo.c -Wall $ ./foo prints on glibc systems: fputs present, gurky missing but on Cygwin 1.7.2: fputs missing, gurky missing With this inability to distinguish present from missing libc symbols, "#pragma weak" is useless to me on Cygwin. Bruno -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple