Opened 11 years ago

Last modified 8 years ago

#6145 new Bugs

MinGW / GCC 4.6.1 warns about conflicts between Boost.Thread and Boost.InterProcess (Win32 C API)

Reported by: Cyril Othenin-Girard <cog@…> Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.48.0 Severity: Problem
Keywords: MinGW interprocess thread warning conflict Cc:

Description

I compile boost-1.48 with GCC 4.6.1 using MinGW-32 3.10 on Windows XP.

My compiling options are :

g++ -std=c++0x

I encounter the following conflicts :

~/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]
~/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]

The problem looks like closed tickets #4217 and #5030.

It looks like "extern C" modifier make the compiler to ignore namespace declarations, hence the conflicts.

For example, discarding namespaces, Boost.Thread declares CreateMutexA() like this :

extern "C"
{
    struct _SECURITY_ATTRIBUTES;
    __declspec(dllimport) void* __stdcall CreateMutexA('''boost::detail::win32::_SECURITY_ATTRIBUTES'''*,int,char const*);
}

whereas Boost.Interprocess declares it like this :

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 *);

To avoid the compiler warnings, the same type should be used for the first parameter of CreateMutexA().

Change History (3)

comment:1 by roffe@…, 9 years ago

I can confirm this with boost 1.54.0 under gcc 4.8.1 / MinGW. Changing the parameters to

void *

in the boost headers seems to fix the problem.

comment:2 by gau_veldt@…, 8 years ago

I still get these warnings in mingw/gcc 4.7.1 on boost 1.56.0 when #include <boost/thread/mutex.hpp> and friends

in reply to:  2 comment:3 by gau_veldt@…, 8 years ago

Replying to gau_veldt@…:

I still get these warnings in mingw/gcc 4.7.1 on boost 1.56.0 when #include <boost/thread/mutex.hpp> and friends

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?

Note: See TracTickets for help on using tickets.