在尝试编译lynx时,我使用了'with-dmalloc'configure选项。但是编译中止了,产生了这个错误:
/usr/include/dmalloc.h:460: error: expected identifier or '(' before '__extension__' > /usr/include/dmalloc.h:484: error: expected identifier or '(' before '__extension__' > make[1]: *** [HTParse.o] Error 1 > make[1]: Leaving directory `/tmp/lynx2-8-8/WWW/Library/Implementation' > make: *** [all] Error 2
这是dmalloc.h中的错误行:
> Line 460: char *strdup(const char *string);
> Linu 484: char *strndup(const char *string, const DMALLOC_SIZE len);
也可以在http://www.filewatcher.com/p/dmalloc-5.5.2.tbz.467309/include/dmalloc.h.html
查看该文件dmalloc上的开发已经停止了,所以并不是真的希望从上游修复。有什么帮助吗?
答案 0 :(得分:3)
我在Fedora 21 x86_64上安装dmalloc时遇到了类似的问题:
dmalloc-5.5.2]$ make
rm -f dmalloc.h dmalloc.h.t
cat ./dmalloc.h.1 dmalloc.h.2 ./dmalloc.h.3 > dmalloc.h.t
mv dmalloc.h.t dmalloc.h
rm -f arg_check.o
gcc -g -O2 -DHAVE_STDARG_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 - DHAVE_UNISTD_H=1 -DHAVE_SYS_MMAN_H=1 -DHAVE_SYS_TYPES_H=1 - DHAVE_W32API_WINBASE_H=0 -DHAVE_W32API_WINDEF_H=0 -DHAVE_SYS_CYGWIN_H=0 - DHAVE_SIGNAL_H=1 -I. -I. -c arg_check.c -o ./arg_check.o
In file included from /usr/include/string.h:634:0,
from arg_check.c:33:
dmalloc.h:484:7: error: expected identifier or ‘(’ before ‘__extension__’
char *strndup(const char *string, const DMALLOC_SIZE len);
^
Makefile:362: recipe for target 'arg_check.o' failed
make: *** [arg_check.o] Error 1
通过改变dmalloc-5.5.2 / dmalloc.h.3解决它:
- 432 | extern
- 433 | char *strndup(const char *string, const DMALLOC_SIZE len);
+ 432 | #undef strndup
+ 433 | extern
+ 434 | char *strndup(const char *string, const DMALLOC_SIZE len);
智慧之源:https://dev.openwrt.org/browser/packages/devel/dmalloc/patches/400-undef-strndup.patch?rev=31253
答案 1 :(得分:0)
我遇到过这样的事情,发现这是由dmalloc.h引起的,例如< unistd.h中>等。这样来自dmalloc.h的宏标识符破坏了真正的valloc / realloc / memdup等的声明。
这可能是你所看到的吗?