Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 319
Richard Whitehead Avatar asked Feb 25 '23 22:02

Richard Whitehead


2 Answers

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
like image 145
Zord Avatar answered Mar 07 '23 06:03

Zord


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.

like image 37
Bryan Avatar answered Mar 07 '23 06:03

Bryan