This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: std=c99 and strdup


Jeffrey Walton <noloader@gmail.com> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]