我正在为一个项目使用 utarray ( uthash 库的一部分)。每当我包含它时,我都会收到以下错误:
utarray.h:221:3: error: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration]
诚然,我在编译 ( -Wall -Wpedantic -Wextra -Werror -pedantic-errors -std=c99
) 时使用了一些非常激进的标志,但我不明白为什么这应该是一个错误。strdup
在string.h
(根据man strdup
)中定义,非常清楚地包含在 中utarray.h
。
我究竟做错了什么?谷歌没有帮助。(显然没有其他人尝试utarray.h
使用这些标志进行编译?)
这是一个无法编译的示例文件(使用gcc -Wall -Wpedantic -Wextra -Werror -pedantic-errors -std=c99 scratch.c
)。
#include "utarray.h"
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return 0;
}
版本:gcc 4.9.2、glibc 2.21、uthash 1.9.9