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.
This is forbidden by the standard since the functions are considered distinct by the language but mangle to the same name.
The standard is perfectly clear in that both declarations refer to the same function (7.5 [dcl.link]/6), and there's no potential for ambiguity since they both denote the same entity. The warning comes from the use of different arguments and/or return type in the declarations. I'm guessing Boost.WinAPI is using winapi's typed handles, while we can see in the warning message that Boost.Thread uses just `void`. Regards, -- Agustín K-ballo Bergé.- http://talesofcpp.fusionfenix.com