Boost C++ Libraries: Ticket #6145: MinGW / GCC 4.6.1 warns about conflicts between Boost.Thread and Boost.InterProcess (Win32 C API) https://svn.boost.org/trac10/ticket/6145 <p> I compile boost-1.48 with GCC 4.6.1 using MinGW-32 3.10 on Windows XP. </p> <p> My compiling options are : </p> <pre class="wiki">g++ -std=c++0x </pre><p> I encounter the following conflicts : </p> <pre class="wiki">~/boost-1.48/interprocess/detail/win32_api.hpp:808:116: warning: declaration of 'void* boost::interprocess::winapi::CreateMutexA(boost::interprocess::winapi::interprocess_security_attributes*, int, const char*)' with C language linkage [enabled by default] ~/boost-1.48/thread/win32/thread_primitives.hpp:119:55: warning: conflicts with previous declaration 'void* boost::detail::win32::CreateMutexA(boost::detail::win32::_SECURITY_ATTRIBUTES*, int, const char*)' [enabled by default] </pre><pre class="wiki">~/boost-1.48/interprocess/detail/win32_api.hpp:813:127: warning: declaration of 'void* boost::interprocess::winapi::CreateSemaphoreA(boost::interprocess::winapi::interprocess_security_attributes*, long int, long int, const char*)' with C language linkage [enabled by default] ~/boost-1.48/thread/win32/thread_primitives.hpp:120:55: warning: conflicts with previous declaration 'void* boost::detail::win32::CreateSemaphoreA(boost::detail::win32::_SECURITY_ATTRIBUTES*, long int, long int, const char*)' [enabled by default] </pre><p> The problem looks like closed tickets <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4217" title="#4217: Bugs: On Mingw-w64-i386 windows 7 plus gcc 4.5.0 gcc version 4.5.0 20100303 ... (closed: fixed)">#4217</a> and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5030" title="#5030: Bugs: Windows API declaration mismatch (closed: invalid)">#5030</a>. </p> <p> It looks like "extern C" modifier make the compiler to ignore namespace declarations, hence the conflicts. </p> <p> For example, discarding namespaces, <strong>Boost.Thread</strong> declares CreateMutexA() like this : </p> <pre class="wiki">extern "C" { struct _SECURITY_ATTRIBUTES; __declspec(dllimport) void* __stdcall CreateMutexA('''boost::detail::win32::_SECURITY_ATTRIBUTES'''*,int,char const*); } </pre><p> whereas <strong>Boost.Interprocess</strong> declares it like this : </p> <pre class="wiki">struct interprocess_security_attributes { unsigned long nLength; void *lpSecurityDescriptor; int bInheritHandle; }; extern "C" __declspec(dllimport) void * __stdcall CreateMutexA('''boost::interprocess::winapi::interprocess_security_attributes'''*, int, const char *); </pre><p> To avoid the compiler warnings, the same type should be used for the first parameter of CreateMutexA(). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6145 Trac 1.4.3 roffe@… Fri, 21 Feb 2014 14:19:47 GMT <link>https://svn.boost.org/trac10/ticket/6145#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6145#comment:1</guid> <description> <p> I can confirm this with boost 1.54.0 under gcc 4.8.1 / MinGW. Changing the parameters to </p> <pre class="wiki">void * </pre><p> in the boost headers seems to fix the problem. </p> </description> <category>Ticket</category> </item> <item> <author>gau_veldt@…</author> <pubDate>Thu, 06 Nov 2014 03:41:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6145#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6145#comment:2</guid> <description> <p> I still get these warnings in mingw/gcc 4.7.1 on boost 1.56.0 when #include &lt;boost/thread/mutex.hpp&gt; and friends </p> </description> <category>Ticket</category> </item> <item> <author>gau_veldt@…</author> <pubDate>Thu, 06 Nov 2014 04:14:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6145#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6145#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6145#comment:2" title="Comment 2">gau_veldt@…</a>: </p> <blockquote class="citation"> <p> I still get these warnings in mingw/gcc 4.7.1 on boost 1.56.0 when #include &lt;boost/thread/mutex.hpp&gt; and friends </p> </blockquote> <p> Hmm... the conflict warnings disappear when I don't use boost::interprocess and friends in conjunction with boost::thread and friends. I guess the ipc and threading headers are incompatible? </p> </description> <category>Ticket</category> </item> </channel> </rss>