[Top][All Lists]

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

Re: [Bug-gnulib] Add strdup.h.

From: Paul Eggert
Subject: Re: [Bug-gnulib] Add strdup.h.
Date: 18 Jan 2004 01:11:07 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Simon Josefsson <address@hidden> writes:

> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ strdup.h  18 Jan 2004 07:54:34 -0000
> @@ -0,0 +1,2 @@
> +/* Duplicate S, returning an identical malloc'd string.  */
> +char *strdup (const char *s);

This doesn't loook portable, since many implementations define strdup
as a macro in <string.h> (which they are entitled to do).  Also, some
older implementations (not conforming to POSIX 2001) define a
prototype where strdup takes a char * argument, not char const *.

It should probably look something like this instead:

#include <string.h>
#if ! HAVE_DECL_STRDUP && ! defined strdup
char *strdup (char const *s);

with the appropriate changes to strdup.m4.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]