[cfe-dev] Latest clang and dllimport

Edward Diener eldlistmailingz at tropicsoft.com
Tue Jul 21 12:36:57 PDT 2015


In the latest clang built from source, if a function is mismatched as to 
a difference in dllimport attributes clang produces an error. As in:

C:\Utilities\mingw-w64\i686-5.1.0-posix-dwarf-rt_v4-rev0\mingw32\i686-w64-mingw32\include\synchapi.h:127:26: 
error: redeclaration of 'Sleep' cannot add 'dllimport' attribute
   WINBASEAPI VOID WINAPI Sleep (DWORD dwMilliseconds);
                          ^
..\..\..\boost/smart_ptr/detail/yield_k.hpp:67:29: note: previous 
declaration is here
   extern "C" void __stdcall Sleep( unsigned long ms );

Changing the latter to:

   extern "C" __declspec(dllimport) void __stdcall Sleep( unsigned long 
ms );

fixes the problem for clang.

Earlier versions of clang ( 3.4.1, 3.5.2, 3.6.1 ) did not have this 
problem. Is there a __has_feature or __has_extension that I can use to 
test this change in the latest clang ? The previous versions are also 
happy with the __declspec(dllimport) added in the declaration so even 
without a __has_feature or __has_extension I can just test for clang on 
Windows, but I like to be as precise as possible in Boost code.








More information about the cfe-dev mailing list