-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Client
-
None
-
Environment:Ubuntu Lucid running mongo-stable
When building a very simple app which includes mongo headers and other boost headers, the app fails to build. The problem is that mongo headers have a #define for malloc which is forced upon your program silently.
This piece of code will fail to compile. The error will indicate that malloc is now mongo::ourmalloc which is most certainly NOT what the user wants. It also causes a conflict with the boost header which has a member function called malloc.
#include <mongo/client/dbclient.h>
#include <boost/pool/pool.hpp>
int main(int argc, char* argv[])
{
malloc();
return 0;
}
error when building:
In file included from /usr/include/boost/pool/pool.hpp:34,
from shit.c:2:
/usr/include/boost/pool/simple_segregated_storage.hpp:99: error: invalid use of '::'
In file included from shit.c:2:
/usr/include/boost/pool/pool.hpp:54: error: invalid use of '::'
/usr/include/boost/pool/pool.hpp:65: error: invalid use of '::'
/usr/include/boost/pool/pool.hpp:219: error: invalid use of '::'
/usr/include/mongo/client/../util/allocator.h: In function 'int main(int, char**)':
/usr/include/mongo/client/../util/allocator.h:22: error: too few arguments to function 'void* mongo::ourmalloc(size_t)'
shit.c:6: error: at this point in file
The expected error here is error: too few arguments to function 'void* malloc(size_t)' when the systems (proper) malloc is used
- related to
-
SERVER-5348 Redefinition of macros while using the C++ driver makes it unusable with larger application code
- Closed