我是osx的新手,但遇到了一些问题。我尝试制作makefile但提出了以下建议:
error: unknown type name 'u_char'; did you mean 'char'?
我提到了 C PCAP library unknown types error,将-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;
}
最佳答案
将-Du_char="unsigned char"
添加到CFLAGS
或仅修复源。在旧版BSD代码库中,使用u_char
作为unsigned char
的懒惰速记是一种常见做法,在这些BSD代码库中,系统 header 历来公开了这种typedef。它不应在现代代码中使用。
关于c - 错误: unknown type name 'u_char' in OSX 10. 11.2,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34229900/