使用 jemalloc, 编译过程出现如下报错:
/usr/include/stdlib.h:589: 错误:‘void* malloc(size_t) throw ()’ 的声明抛出不同的异常 /usr/include/stdlib.h:592: 错误:‘void* calloc(size_t, size_t) throw ()’ 的声明抛出不同的异常 /usr/include/stdlib.h:601: 错误:‘void* realloc(void*, size_t) throw ()’ 的声明抛出不同的异常 /usr/include/stdlib.h:603: 错误:‘void free(void*) throw ()’ 的声明抛出不同的异常 /usr/include/stdlib.h:617: 错误:‘void* valloc(size_t) throw ()’ 的声明抛出不同的异常
再看 jemalloc 的 manpage, 原来, 是必须在 include jemalloc 之前先 include stdlib.h.
#include <stdlib.h> #include <jemalloc/jemalloc.h>