我的函数宏有以下问题.这一直有效,直到我添加了print_heavyhitters函数.我在m61.h中有这个:
#if !M61_DISABLE
#define malloc(sz) m61_malloc((sz), __FILE__, __LINE__)
#define free(ptr) m61_free((ptr), __FILE__, __LINE__)
#define realloc(ptr, sz) m61_realloc((ptr), (sz), __FILE__, __LINE__)
#define calloc(nmemb, sz) m61_calloc((nmemb), (sz), __FILE__, __LINE__)
#define print_heavyhitters(sz) print_heavyhitters((sz), __FILE__, __LINE__)
#endif
Run Code Online (Sandbox Code Playgroud)
在m61.c中,所有这些函数都很好,除了print_heavyhitters(sz).我得到" - 函数print_heavyhitters上的宏使用错误:
- Macro usage error for macro:
print_heavyhitters
- Syntax error
Run Code Online (Sandbox Code Playgroud)
m61.c:
#include "m61.h"
...
void *m61_malloc(size_t sz, const char *file, int line) {...}
void print_heavyhitters(size_t sz, const char *file, int line) {...}
Run Code Online (Sandbox Code Playgroud)