|
Boost : |
Subject: Re: [boost] [winapi] [thread] Conflicting declarations on MinGW
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2015-12-31 09:58:49
On 2015-12-31 17:50, AgustÃn K-ballo Bergé wrote:
> On 12/31/2015 11:32 AM, Andrey Semashev wrote:
>> On 2015-12-31 15:47, AgustÃn K-ballo Bergé wrote:
>>> On 12/31/2015 7:59 AM, Andrey Semashev wrote:
>>>> On 2015-12-31 13:40, Antony Polukhin wrote:
>>>>> Hi,
>>>>>
>>>>> Some of the Boost.DLL tests produce following warnings:
>>>>>
>>>>> ../boost/thread/win32/thread_primitives.hpp:175:83: warning:
>>>>> declaration of
>>>>> 'void* boost::detail::win32::GetModuleHandleA(const char*)' with C
>>>>> language
>>>>> linkage
>>>>> ../boost/detail/winapi/dll.hpp:47:1: warning: conflicts with previous
>>>>> declaration 'HINSTANCE__*
>>>>> GetModuleHandleA(boost::detail::winapi::LPCSTR_)'
>>>>> ../boost/thread/win32/thread_primitives.hpp:195:94: warning:
>>>>> declaration of
>>>>> 'int (__attribute__((__stdcall__)) *
>>>>> boost::detail::win32::GetProcAddress(void*, const char*))()' with C
>>>>> language linkage
>>>>> ../boost/detail/winapi/dll.hpp:82:1: warning: conflicts with previous
>>>>> declaration 'int (__attribute__((__stdcall__)) *
>>>>> GetProcAddress(boost::detail::winapi::HMODULE_,
>>>>> boost::detail::winapi::LPCSTR_))()'
>>>>>
>>>>>
>>>>> Andrey, Vicente what's the best way to resolve such issues?
>>>>
>>>> IMO, Boost.Thread needs to be ported to Boost.WinAPI.
>>>> boost/thread/win32/thread_primitives.hpp declares extern "C" functions
>>>> in its own namespace, while Windows SDK and Boost.WinAPI declare
>>>> them in
>>>> the global namespace.
>>>
>>> Declaring extern "C" functions in a namespace is perfectly fine.
>>> Frankly, I'm surprised and disappointed that Boost.WinAPI does not do
>>> it, and that it will litter the global namespace instead.
>>
>> It did, until it caused problems with clang - similar to the ones quoted
>> by Antony above.
>
> I made a little experiment to try to understand what you are saying:
>
> http://melpon.org/wandbox/permlink/ncVqjnyzuTlepx2F
>
> As you can see, this reproduces both the gcc warning and a clang error,
> but only for the conflicting declaration of `bar`. The difference in
> namespace for `foo` is irrelevant, as the standard says.
Ok, but it doesn't really matter. Boost.WinAPI does re-define some of
the Windows SDK structs, so it has to duplicate affected functions as
well. The declarations in the global namespace are mirroring the real
declarations in Windows SDK; these names are considered reserved anyway
because including Windows SDK headers may result in these names being
used. boost::detail::winapi::* symbols are considered the interface for
Boost libraries.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk