Menu

#128 redefining strndup causes "error: expected identifier or '(' before '__extension__'"

branch-1.6.x
closed-accepted
None
5
2016-01-22
2015-12-31
No

We check for the availability of strndup and strnlen with autoconf macros. However, if they are available, we still define our own extern prototype for them. Recent glibcs have a slightly different prototype which causes a compile error against ours. This change arose at some point between glibc 2.13 and 2.19.

In file included from /usr/include/string.h:634:0,
from src/api/UpnpString.c:23:
src/api/UpnpString.c:47:15: error: expected identifier or '(' before 'extension'
extern char strndup(__const char __string, size_t __n);
^
Makefile:1266: recipe for target 'src/api/libupnp_la-UpnpString.lo' failed
make[5]: *** [src/api/libupnp_la-UpnpString.lo] Error 1

Most obvious fix is to not redefine them if autoconf tells us they are available anyway, see patch.

Discussion

  • Nick Leverton

    Nick Leverton - 2015-12-31
     

    Last edit: Nick Leverton 2015-12-31
  • Marcelo Roberto Jimenez

    • assigned_to: Nick Leverton
     
  • Marcelo Roberto Jimenez

    Nick,

    Committed!

    But for some reason, your patch did not apply, I had to do some changes, please check.

    Regards,
    Marcelo.

     
  • Nick Leverton

    Nick Leverton - 2016-01-16

    Hi Marcelo, the fix as applied looks good and builds, thanks. Not sure why my patch differed from mainstream.

     
  • Marcelo Roberto Jimenez

    • status: open --> closed-accepted
     
MongoDB Logo MongoDB