Re: std=c99 and strdup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeffrey Walton <noloader@xxxxxxxxx> writes:

> I'm getting "warning: implicit declaration of function ‘strdup’".
>
> The man pages tell me to include string.h. In string.h (which is included):
>
> #if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED
> /* Duplicate S, returning an identical malloc'd string.  */
> extern char *strdup (__const char *__s)
>      __THROW __attribute_malloc__ __nonnull ((1));
> #endif
>
> I feel like I'm missing something since strdup is guarded with
> library/operating system macros. Can anyone point out my mistake? Or
> should I just declare it extern myself?

I assume you are using GNU/Linux or some other glibc-based system.  Try
using -D_GNU_SOURCE when you compile.

Ian



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux