[uClibc] problem of strdup

Dave Hylands dhylands at broadcom.com
Tue Mar 1 14:17:36 UTC 2005


Try adding:
 
#include <string.h>
 
since this is where strdup is defined. The reason it compiles OK on gcc is
because your warning level is too low. If you were to try:
 
arm-linux-uclibc-gcc -Wall test.c -o test
 
you would find that you get the warning on the original code. C++ can't
afford to be so lax due to typesafe linking.



--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/ 

	-----Original Message-----
	From: uclibc-bounces at uclibc.org [mailto:uclibc-bounces at uclibc.org] On
Behalf Of kirbyzhu
	Sent: Tuesday, March 01, 2005 3:16 AM
	To: uclibc at uclibc.org
	Subject: [uClibc] problem of strdup
	
	
	hi everyone:
	 
	   I am build a gcc-2.95 uclibc toolchain for arm with
uClibc-snapshot.tar.bz2.
	 
	When I compile  code like this:
	 
	//test.c
	#include <stdio.h>
	 
	int main(void)
	{
	    char* s=NULL;
	 
	    s = strdup("hello");
	 
	    return 0; 
	}
	 
	 
	If I compile it: arm-linux-uclibc-g++ test.c -o test
	 
	The compiler get some error like:
	 
	test.c: In function `int main()':
	test.c:7: implicit declaration of function `int strdup(...)'
	test.c:7: assignment to `char *' from `int' lacks a cast
	 
	But I use: arm-linux-uclibc-gcc test.c -o test,it is compile ok.
	 
	Can anybody tell me why? Thanks!
	 
	 
	 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.busybox.net/pipermail/uclibc/attachments/20050301/81f42730/attachment-0001.htm 


More information about the uClibc mailing list