On Sun, 20 Aug 2000, Jeremy Buchmann wrote:
> First, thanks to Scott, Tom, and Jonathan for telling me where my compiler
> defines stuff :P
>
> Second, I have now found that I get the error: 'strdup' undeclared...
>
> I noticed some lines in the i386 section of machine.h that extern'd strdup()
> and bcopy(), so I copied those into my powerpc section, but I still got the
> errors...any ideas?
>
> Jeremy Buchmann
> buchmann@xxxxxxxxxx
On my machine, strdup is defined by a macro guarded by a bunch of #ifdef
tests. Including <string.h> _should_ get you that macro. (the actual
macro is in string2.h).
If all else fails you can write your own strdup
char *
strdup(const char * s)
{
size_t len = strlen(s)+1;
char * retval = (char *)malloc(len);
if (retval != NULL) memcpy(retval, s, len);
return retval;
}
later.
scott
|