Boost logo

Boost :

Subject: Re: [boost] [winapi] Problem with the latest clang on Windows
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2015-06-01 13:13:58


Le 01/06/15 10:02, Andrey Semashev a écrit :
> On Sunday 31 May 2015 20:07:43 Edward Diener wrote:
>> Updates to clang on Windows have broken the use of clang with the
>> [winapi] library. I do not know if this has occurred in the past but it
>> seems to have occurred recently when I build the latest clang from
>> source and use it on Windows to compile build Boost libraries which use
>> the internal winapi library.
>>
>> Preprocessing clang and gcc output for a given call in the Boost winapi
>> library and in the corresponding mingw windows.h shows that both
>> compilers view the same source but treat them differently.
>>
>> As an example let's look at the GetSystemTimeAsFileTime call. The
>> preprocessed source for both clang and gcc shows:
>>
>> In the Boost winapi it is:
>>
>> __attribute__((dllimport)) void __attribute__((__stdcall__))
>> GetSystemTimeAsFileTime(FILETIME_* lpFileTime);
>>
>> In the mingw/gcc windows.h it is:
>>
>> void __attribute__((__stdcall__)) GetSystemTimeAsFileTime(LPFILETIME);
>>
>> where the FILETIME_ and LPFILETIME are the same.
>>
>> When gcc sees these two declarations in the two different headers it
>> says everything is OK.
>>
>> When clang sees these two declarations in the two different headers it
>> gives an error:
>>
>> In file included from test_winapi.cpp:9:
>> In file included from /mingw/include\windows.h:62:
>> /mingw/include\winbase.h:1397:24: error: conflicting types for
>> 'GetSystemTimeAsFileTime'
>> WINBASEAPI void WINAPI GetSystemTimeAsFileTime(LPFILETIME);
>> ^
>> ..\..\..\boost/detail/winapi/time.hpp:70:9: note: previous declaration
>> is here
>> GetSystemTimeAsFileTime(FILETIME_* lpFileTime);
>> ^
>>
>> For this line in boost/detail/winapi/time.hpp
>>
>> __declspec(dllimport) void WINAPI
>> GetSystemTimeAsFileTime(FILETIME_* lpFileTime);
>>
>> It seems like the fix for clang is to leave out the
>> __declspec(dllimport) portion of all these Boost winapi calls while
>> leaving it in for everybody else. I am discussing this on the clang
>> developers mailing list but it seems like they are pretty adamant that
>> if they see __attribute__((dllimport)) in from of a function declaration
>> and do not see it in front of another function declaration, despite the
>> rest of the signatire being the same, the two declarations are not the
>> same function being declared and therefore an error because of ODR.
> There's this possibly related ticket:
>
> https://svn.boost.org/trac/boost/ticket/11338

I have no access to a windows environment.

I could create a branch and do my best to port to Boost.WinAPI if
someone is ready to test it.

I would also accept any working patch.

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk