简体   繁体   中英

boost::thread compilation error in Visual Studio 2010

I'm trying ot use boost for the first time in a long while and when I include the boost/thread.hpp header I get a compilation error inside boost itself:

    c:\myproj\boost_1_46_0\boost\thread\win32\thread_heap_alloc.hpp(97): error C2061: syntax error : identifier 'heap_memory
    c:\myproj\boost_1_46_0\boost\thread\detail\thread.hpp(134) : see reference to function template instantiation 'T *boost::detail::heap_new<boost::detail::thread_data<F>,void(__cdecl *)(void)>(A1 &&)' being compiled
    with
    [
        T=boost::detail::thread_data<void (__cdecl *)(void)>,
        F=void (__cdecl *)(void),
        A1=void (__cdecl *)(void)
    ]`

This happens just by including the header, it doesn't seem to have anything to do with my code, but I can't see what to do about it, can anyone help?

If you're using the MSVC wizard, make sure to include the boost header

#include <boost/thread/thread.hpp>

before the generated block

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

It's possible you #included some other package that has a #define of 'new', which then breaks what Boost is trying to do with placement new. To see the code after pre-processing, compile with /P or /E and then search for this line in the output and see if it looks different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM