Looking in the string.h
on my platform (linux, gnu libc 2.16) I found :
#if defined __USE_SVID || defined __USE_BSD || defined __USE_XOPEN_EXTENDED \
|| defined __USE_XOPEN2K8
/* Duplicate S, returning an identical malloc'd string. */
extern char *strdup (const char *__s)
__THROW __attribute_malloc__ __nonnull ((1));
#endif
The #if
s are slightly different, I don't know the influence between those I found in my header and the ones your are using.
About the second question, you could use the autotools to create a config.h
header describing the capabilities of the compiling platform, and use your own versions of missing functions.
In addition you could also use the gnulib "source library" which provides implementation of defective or missing functions (like strdup
)
Using autotools should prevent any redeclaration error.