hyrathb / mentohust

mentohust加入v4支持
467 stars 75 forks source link

ubuntu下编译出现 "u_char" 未定义的问题 #269

Open weiguang opened 8 years ago

weiguang commented 8 years ago

我下载了源码编译之后出现了u_char" 未定义。我编译googlecode的源码可以编译成功。

ubuntu 编译: sh autogen.sh ./configure --prefix=/usr make CFLAGS+=-std=c99

结果:unknown type name ‘u_char’ make[2]: Entering directory '/home/jam/mentohust/src' CC myconfig.o In file included from myconfig.c:20:0: myfunc.h:20:26: error: unknown type name ‘u_char’ void fillMd5Packet(const u_char md5Seed); / 填充Md5包 _/ ^ myfunc.h:21:21: error: unknown type name ‘u_char’ void fillEchoPacket(uchar *buf); / 填充Echo包 _/ ^ myfunc.h:22:23: error: unknown type name ‘u_char’ void getEchoKey(const uchar *capBuf); / 获取EchoKey _/ ^ myfunc.h:23:1: error: unknown type name ‘u_char’ u_char checkPass(u_char id, const u_char md5Seed, int seedLen); / 计算密码的md5 / ^ myfunc.h:23:19: error: unknown type name ‘u_char’ u_char checkPass(u_char id, const u_char md5Seed, int seedLen); / 计算密码的md5 / ^ myfunc.h:23:36: error: unknown type name ‘u_char’ u_char checkPass(u_char id, const u_char md5Seed, int seedLen); / 计算密码的md5 / ^ myfunc.h:24:21: error: unknown type name ‘u_char’ void fillCernetAddr(uchar *buf); / 填充赛尔网络地址 _/ ^ myconfig.c:60:8: error: unknown type name ‘u_char’ extern uchar version[]; / 版本 _/ ^ myconfig.c:72:1: error: unknown type name ‘u_char’ uchar localMAC[6]; / 本机MAC _/ ^ myconfig.c:73:1: error: unknown type name ‘u_char’ uchar destMAC[6]; / 服务器MAC _/ ^ myconfig.c: In function ‘initConfig’: myconfig.c:261:5: error: ‘u_char’ undeclared (first use in this function) ((u_char )&gateway)[3] = 0x02; ^ myconfig.c:261:5: note: each undeclared identifier is reported only once for each function it appears in myconfig.c:261:13: error: expected expression before ‘)’ token ((u_char )&gateway)[3] = 0x02; ^ myconfig.c: In function ‘checkRunning’: myconfig.c:625:4: warning: implicit declaration of function ‘kill’ [-Wimplicit-function-declaration] if (kill(fl.lpid, SIGINT) == -1) ^ myconfig.c:639:3: warning: implicit declaration of function ‘daemon’ [-Wimplicit-function-declaration] if (daemon(0, (daemonMode+1)%2)) ^ Makefile:420: recipe for target 'myconfig.o' failed make[2]: ** [myconfig.o] Error 1

weiguang commented 8 years ago

我认为是加了c99编译的原因。因为我在编译0.3.1算法的时候加入 c99编译也是出现这个问题。 在网上找到了错误。但是不知道怎么改呢、、 http://stackoverflow.com/questions/15466342/why-uint-from-sys-types-h-disappears-using-std-c99/15466411#15466411

updateing commented 8 years ago

如果单纯为了编译的话,可以typedef unsigned char u_char;来解决。

这里对于u_char的解释更确切一些: http://stackoverflow.com/questions/1918934/is-u-char-a-standard

hyrathb commented 8 years ago

嗯,我是不会考虑用这些类型的,希望谁有时间能重构一下代码,毕竟老代码和新代码质量都不高……

weiguang commented 8 years ago

我已经把c99那个for循环修改了一下。可以编译了。我是华南农业大学的, 学校增加了接入方式,以区分办公账号和学生账号。以前的代码不支持办公账号,我抓包看了协议,start包后面增加了字段。所以我修改代码增加了一个参数S,现在可以支持了。我可以把代码整合上去吗?

hyrathb commented 8 years ago

你可以开一个pull request,多谢,能支持更多当然更好。

hyrathb commented 8 years ago

之前一直忘记改掉那个循环了