This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ANSI C / assignment makes pointer from integer
Sebastian Ude <ude@handshake.de> writes:
> I *did* include string.h.
But strdup is not part of ANSI C, check:
gee:~/tmp:[0]$ gcc -Wall -ansi str.c
str.c: In function `main':
str.c:5: warning: implicit declaration of function `strdup'
str.c:5: warning: initialization makes pointer from integer without a cast
str.c:5: warning: unused variable `s'
implicit declared functions return int...
Andreas
> Guess why I placed the
>
> [...]'s
>
> Yep, to tell you that I left out some lines of code which seemed natural to
> me.
>
> Try this complete example:
>
> #include <string.h>
>
> int main(void)
> {
> char *s = strdup("foo");
> return 0;
> }
>
> string.h is included, so the definition of strdup() should be present.
> But the warning is still there when compiling with -ansi ...
>
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
PGP signature