Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: unknown type name 'u_char' in OSX 10.11.2

I'm new to osx and I have some problems.I tried to makefile but come up with: error: unknown type name 'u_char'; did you mean 'char'?

I referred to C PCAP library unknown types error ,add -D_BSD_SOURCE CFLAGS to my makefile, but it doesn't help.What am I missing?

EDIT:

This is the code which produces the error:

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;
}
like image 976
Jian Guo Avatar asked Dec 11 '15 18:12

Jian Guo


1 Answers

Add -Du_char="unsigned char" to CFLAGS or just fix the source. Using u_char as lazy shorthand for unsigned char was a common practice in legacy BSD codebases where the system headers historically exposed such a typedef. It should not be used in modern code.

like image 136
R.. GitHub STOP HELPING ICE Avatar answered Oct 13 '22 01:10

R.. GitHub STOP HELPING ICE