Michael IV
Michael IV

Reputation: 11446

Boost pool malloc() and free() compiler error

I am using Boost 1.58 64bit, VC++ 2013 ,64bit project.Using boost::pool.

previously used Boost 1.54 and had no problems with calling:

 boost::pool  malloc() 

and

 boost::pool free(p)

Now, both methods are throwing:

error C2039: '_malloc_dbg' : is not a member of 'boost::pool'

and

error C2039: '_free_dbg' : is not a member of 'boost::pool'

accordingly.

Do I miss any directive to cause the compiler treat malloc and free as pool class members?

UPDATE:

I see it happens only inside the header inline methods.If I call them in .cpp I have no errors.

Example:

inline void* MemoryManager::AllocMemory(){

    return  m_pool->malloc();
}

throws compiler errors.

Upvotes: 1

Views: 356

Answers (1)

alain
alain

Reputation: 12047

crtdbg.h from Windows contains the lines:

#ifdef  _CRTDBG_MAP_ALLOC

#define   malloc(s)             _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define   calloc(c, s)          _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
#define   realloc(p, s)         _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
...

Try to #undef _CRTDBG_MAP_ALLOC

Edit: #define _AFX_NO_DEBUG_CRT should prevent crtdbg.h from being included. Add it to the project settings, or before including any Windows headers.

Upvotes: 4

Related Questions