weak symbols on Cygwin

Charles Wilson cygwin@cwilson.fastmail.fm
Wed Apr 7 12:35:00 GMT 2010


On 4/7/2010 5:06 AM, Bruno Haible wrote:
> I've got some code, written for ELF platforms, that detects whether the pthread
> library (often a separate library from libc) is linked, by doing
> 
>   #pragma weak pthread_cancel
>   bool pthread_in_use = (pthread_cancel != NULL);
> 
> This code breaks in Cygwin 1.7, because the autoconf test determines that gcc
> accepts #pragma weak. Not a big problem - I can surround that code with
>   #ifdef __ELF__

And on cygwin, since the pthread functionality is IN cygwin1.dll, you
can never link a cygwin-based DLL or EXE without having the pthread
symbols present.  So, if you want to support "with threading" vs.
"without threading" on cygwin, you have to have a configure time option,
instead:

#ifdef __ELF__
bool pthread_in_use = (pthread_cancel != NULL);
#elif defined(__CYGWIN__) and !defined(NO_THREADS)
bool pthread_in_use = true;
#else
bool pthread_in_use = false;
#endif

or something.

--
Chuck

--
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



More information about the Cygwin mailing list