在 Windows 平台上面,引入由VCPKG部署编译的 JEMALLOC 是无法调用 JE_MALLOC、JE_FREE 函数的,除非对库头文件进行魔改,一个好的办法是显示声明并导入函数签名。
在其它平台上面必须定义:JEMALLOC_NO_DEMANGLE 编译器预处理宏,否则是无法调用 JE_MALLOC、JE_FREE 等函数的。
#if defined(JEMALLOC)
#if defined(_WIN32)
#if defined(__cplusplus)
extern "C" {
#endifvoid* je_malloc(size_t size);void je_free(void* size);int je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
#if defined(__cplusplus)
}
#endif// Under the Windows platform, the default project compiled by microsoft vcpkg jemalloc for windowos does not have the C/C++ compiler macro version information,
// And the compiler user needs to manually define it in this header file so that it can be included in the help information.
// Displays the library version information that is directly dependent.
//
// Jemalloc compiled by vcpkg on windows, version macro information summary: Windows 0.0.0-0-g000000missing_version_try_git_fetch_tags
#if !defined(JEMALLOC_VERSION_MAJOR) && !defined(JEMALLOC_VERSION_MINOR) && !defined(JEMALLOC_VERSION_BUGFIX) && !defined(JEMALLOC_VERSION_NREV)
#define JEMALLOC_VERSION_MAJOR 5
#define JEMALLOC_VERSION_MINOR 3
#define JEMALLOC_VERSION_BUGFIX 0
#define JEMALLOC_VERSION_NREV 0
#endif
#else
#define JEMALLOC_NO_DEMANGLE
#include <jemalloc/jemalloc.h>
#endif
#endif