1

While trying to compile lynx, I used the 'with-dmalloc' configure option. But compilation aborted, producing this error:

 /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

This is what the errant lines in dmalloc.h hold:


> Line 460: char *strdup(const char *string);
> Linu 484: char *strndup(const char *string, const DMALLOC_SIZE len);

The file can also be viewed at http://www.filewatcher.com/p/dmalloc-5.5.2.tbz.467309/include/dmalloc.h.html

Development on dmalloc has pretty much stopped, so not really expecting a fix from upstream. Any help?

Gray
  • 115,027
  • 24
  • 293
  • 354
KNMC
  • 11
  • 4

2 Answers2

3

I faced with the similar problem while installing dmalloc on Fedora 21 x86_64:

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

Solved it by altering 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);

The source of wisdom: https://dev.openwrt.org/browser/packages/devel/dmalloc/patches/400-undef-strndup.patch?rev=31253

rdiachenko
  • 696
  • 9
  • 15
0

I encountered something like this and found that this was caused by the dmalloc.h was included before e.g. <unistd.h> et. al so that the macro identifiers from dmalloc.h mangled the declarations for the real valloc/realloc/memdup etc.

Could this be what you are seeing?

Thomas Padron-McCarthy
  • 27,232
  • 8
  • 51
  • 75
thoni56
  • 3,145
  • 3
  • 31
  • 49