Trouble with precompiled binaries and USE_DECLSPEC_THREAD

Vassilis Radis <>
Tue Dec 1 23:28:50 CET 2009


The windows binaries available for download are compiled with
USE_DECLSPEC_TRHEAD.
This, according to the following link:

http://msdn.microsoft.com/en-us/library/2s9wt68x.aspx

can cause trouble on systems before Vista when using _declspec(thread)
compiled modules via LoadLibrary. It did happen to me with the ei libraries,
which I needed to use by wrapping them in a dll which was called by .net
with LoadLibrary. On windows XP, in order to work with the dll that wrapped
the ei libs using LoadLibrary, I needed to recompiled sources with cygwin
and remove USE_DECLSPEC_THREAD. On Vista it works out of the box.

There is a catch though when recompiling: When you remove the
USE_DECLSPEC_THREAD definition from the compiler args, the code fragment
that gets included due to the removal (TLS API calls in ei_pthreads.c)
contains a call to SwitchToThread which needs <winbase.h>. Winbase.h is
included in ei.h .But there is something wrong with the include order or the
/D compiler definitions order, which causes an unresolved symbol for
SwitchToThread() and i had to explicitly re-include winbase.h in
ei_pthreads.c

I would suggest defining USE_DECLSPEC_THREAD via a test for version (WINVER
or WIN32_WINNT or something, i cant remember now).


Sorry for not giving more details and maybe provide a patch suggestion, but
cygwin got uninstalled and I dont have VC++ on my machine.
If you cant reproduce and verify the problem easily please tell me and I
will try to get access to VC++ 2005 and reproduce details.

Thanks,
Vassilis


More information about the erlang-bugs mailing list