Jia*_*Guo 5 c makefile gnu-make
我是 osx 的新手,我遇到了一些问题。我尝试生成文件,但提出了:
error: unknown type name 'u_char'; did you mean 'char'?
我提到 C PCAP 库未知类型错误,将-D_BSD_SOURCE
CFLAGS添加到我的 makefile,但它没有帮助。我错过了什么?
编辑:
这是产生错误的代码:
char *computePwd(const u_char *md5) {
static char buf[16];
unsigned char tmp[40];
int tmpl=0;
tmpl = strlen(userName);
strcpy((char*)tmp, userName);
memcpy(tmp + tmpl, md5, 16);
tmpl += 16;
memcpy(buf, ComputeHash(tmp, tmpl), 16);
memset(tmp, 0, 16);
strcpy((char*)tmp, password);
int i;
for (i=0; i<16; ++i)
buf[i] ^= tmp[i];
return buf;
}
Run Code Online (Sandbox Code Playgroud)
添加-Du_char="unsigned char"
到CFLAGS
或刚修好的来源。在遗留 BSD 代码库中使用u_char
惰性速记unsigned char
是一种常见的做法,其中系统标头历史上暴露了这样的类型定义。它不应该在现代代码中使用。