Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#4217 closed Bugs (fixed)

On Mingw-w64-i386 windows 7 plus gcc 4.5.0 gcc version 4.5.0 20100303 (experimental) (GCC) compiling error.

Reported by: anonymous Owned by: Peter Dimov
Milestone: Boost 1.43.0 Component: smart_ptr
Version: Boost 1.44.0 Severity: Problem
Keywords: Cc: feiyunw@…

Description

./boost/thread/win32/thread_primitives.hpp:123:73: warning: declaration of 'void boost::detail::win32::Sleep(long unsigned int)' with C language linka ge ./boost/smart_ptr/detail/yield_k.hpp:58:29: warning: conflicts with previous declaration 'void boost::detail::Sleep(unsigned int)' In file included from ./boost/thread/once.hpp:14:0,

from libs\thread\src\win32\thread.cpp:17:

./boost/thread/win32/once.hpp: In destructor 'boost::once_flag::~once_flag()': ./boost/thread/win32/once.hpp:47:35: error: '_InterlockedExchange' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp: In function 'void* boost::detail::allocate_event_handle(void*&)': ./boost/thread/win32/once.hpp:65:32: error: '_InterlockedCompareExchange' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp: In function 'void boost::call_once(boost::once_flag&, Function)': ./boost/thread/win32/once.hpp:92:20: error: '_InterlockedCompareExchange' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:108:25: error: '_InterlockedIncrement' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:111:21: error: '_InterlockedExchange' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:128:25: error: '_InterlockedIncrement' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:130:21: error: '_InterlockedExchange' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:145:17: error: '_InterlockedIncrement' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:164:17: error: '_InterlockedExchangeAdd' is not a member of 'boost::detail' ./boost/thread/win32/once.hpp:172:21: error: '_InterlockedExchange' is not a member of 'boost::detail' libs\thread\src\win32\thread.cpp: In static member function 'static unsigned int boost::thread::hardware_concurrency()': libs\thread\src\win32\thread.cpp:307:28: warning: missing braces around initializer for '_SYSTEM_INFO::<anonymous union>' libs\thread\src\win32\thread.cpp: In function 'LARGE_INTEGER boost::this_thread::<unnamed>::get_due_time(const boost::detail::timeout&)': libs\thread\src\win32\thread.cpp:330:42: warning: missing braces around initializer for '_LARGE_INTEGER::<anonymous struct>'

"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -mthreads -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_LIB=1 -I"." -c -o "bin.v2\libs\thread\b

uild\gcc-mingw-4.5.0\debug\link-static\threading-multi\win32\thread.o" "libs\thread\src\win32\thread.cpp"

...failed gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi\win32\thread.o... gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi\win32\tss_dll.o gcc.compile.c++ bin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi\win32\tss_pe.o ...skipped <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi>libboost_thread-mgw45-mt-d-1_43.a(clean) for lack of <pbin.v2\ libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi>win32\thread.o... ...skipped <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi>libboost_thread-mgw45-mt-d-1_43.a for lack of <pbin.v2\libs\th read\build\gcc-mingw-4.5.0\debug\link-static\threading-multi>win32\thread.o... ...skipped <pstage\lib>libboost_thread-mgw45-mt-d-1_43.a for lack of <pbin.v2\libs\thread\build\gcc-mingw-4.5.0\debug\link-static\threading-multi>libb oost_thread-mgw45-mt-d-1_43.a... common.mkdir bin.v2\libs\wave common.mkdir bin.v2\libs\wave\build

Change History (6)

comment:1 by Steven Watanabe, 12 years ago

Component: buildthread
Owner: changed from Vladimir Prus to Anthony Williams

comment:2 by feiyunw@…, 12 years ago

Cc: feiyunw@… added

I got compile-time warnings with ogre-1.7.1 and boost-1.43.0 thread:

[  0%] Building CXX object OgreMain/CMakeFiles/OgreMain.dir/src/OgreAlignedAllocator.cpp.obj
cd OgreMain && C:\MinGW\bin\g++.exe   -DOgreMain_EXPORTS -D_WIN32_WINNT=0x0500 -DBOOST_ALL_NO_LIB -DOGRE_NONCLIENT_BUILD -DFREEIMAGE_LIB -D_MT -D_USRDLL -O3 -DNDEBUG -ID:\prj\ogre\ogre-1.7\OgreMain\include -I..\include -ID:\prj\ogre\ogre-1.7\Dependencies\include -ID:\prj\ogre\ogre-1.7\Dependencies\include\OIS -ID:\prj\ogre\ogre-1.7\Dependencies\include\Cg -IC:\PROGRA~1\MI21AE~1\Include -IC:\boost\include\boost-1_43 -ID:\prj\ogre\ogre-1.7\OgreMain\include\WIN32 -ID:\prj\ogre\ogre-1.7\OgreMain\src\nedmalloc   -msse -o CMakeFiles\OgreMain.dir\src\OgreAlignedAllocator.cpp.obj -c D:\prj\ogre\ogre-1.7\OgreMain\src\OgreAlignedAllocator.cpp
In file included from C:\boost\include\boost-1_43/boost/thread/win32/thread_heap_alloc.hpp:8:0,
                 from C:\boost\include\boost-1_43/boost/thread/detail/thread_heap_alloc.hpp:15,
                 from C:\boost\include\boost-1_43/boost/thread/tss.hpp:10,
                 from D:\prj\ogre\ogre-1.7\OgreMain\include/Threading/OgreThreadHeadersBoost.h:29,
                 from D:\prj\ogre\ogre-1.7\OgreMain\include/Threading/OgreThreadHeaders.h:30,
                 from D:\prj\ogre\ogre-1.7\OgreMain\include/OgreStdHeaders.h:110,
                 from D:\prj\ogre\ogre-1.7\OgreMain\include/OgrePrerequisites.h:315,
                 from D:\prj\ogre\ogre-1.7\OgreMain\src\OgreAlignedAllocator.cpp:30:
C:\boost\include\boost-1_43/boost/thread/win32/thread_primitives.hpp:123:73: warning: declaration of 'void boost::detail::win32::Sleep(long unsigned int)' with C language linkage
C:\boost\include\boost-1_43/boost/smart_ptr/detail/yield_k.hpp:58:29: warning: conflicts with previous declaration 'void boost::detail::Sleep(unsigned int)'

My environment is Windows XP (Chinese version, 32bit)/MinGW/g++-4.5.0. The reason is that Sleep() parameter type mismatches. In boost/thread/win32/thread_primitives.hpp:

namespace boost
{
    namespace detail
    {
        namespace win32
        { ...
            extern "C"
            { ...
                __declspec(dllimport) void __stdcall Sleep(unsigned long);

while in boost/smart_ptr/detail/yield_k.hpp:

namespace boost
{
namespace detail
{
#if !defined( BOOST_USE_WINDOWS_H )
  extern "C" void __stdcall Sleep( unsigned ms );
#endif

It looks like "extern C" modifier will make the function ignore namespace declaration. This makes sense as the function is defined in another module where we can't export namespace constraints. We should correct the parameter type to stop the compiler warnings.

comment:3 by Peter Dimov, 12 years ago

Component: threadsmart_ptr
Owner: changed from Anthony Williams to Peter Dimov
Status: newassigned

'unsigned long' is correct according to <wtypes.h>, reassigning to myself.

comment:4 by Peter Dimov, 12 years ago

(In [62246]) DWORD is unsigned long, not unsigned int. Refs #4217.

comment:5 by Peter Dimov, 12 years ago

Resolution: fixed
Status: assignedclosed

(In [63826]) Merge [62246] to release. Fixes #4217.

comment:6 by Hesh, 10 years ago

Hello,

I am using Ubuntu, codeBlocks, , boost 1.46 in GCC 4.7 [ yield_k.hpp ] I get this error ' error : Sleep was not declared in this scope' tried #include <unistd.h> and Sleep to sleep, nothing worked. when I change it to sleep 'error:expected initializer before 'sleep how Do I resolve this issue ??

Note: See TracTickets for help on using tickets.