This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ANSI C / assignment makes pointer from integer




On Tue, 7 Aug 2001, fjh@cs.mu.oz.au (Fergus Henderson) wrote:
> Date: Tue, 7 Aug 2001 22:39:11 +1000
> To: Bohdan Vlasyuk <bohdan@kivc.vstu.vinnica.ua>
> From: fjh@cs.mu.oz.au (Fergus Henderson)
> CC: Sebastian Ude <ude@handshake.de>, gcc@gcc.gnu.org
> Subject: Re: ANSI C / assignment makes pointer from integer

[...]

> Actually it's a bit more complicated than that.
> strdup() is a non-standard function, so as well as #including <string.h>,
> you also need to compile with the right options; if you compile with
> `ansi', then strdup() will not be declared even if you #include
> <string.h>.
> 
> If you want to write standard-conforming code, don't use strdup().
> 
> The simplest solution is to write a version of strdup() yourself,
> name it something different, e.g. `sebastian_strdup()', and use that.

That's intresting.
In fact, the strdup manual page says that it's a BSD / SVID invention, but
it seems not to be defined through the ISO / ANSI C standard.

Compiling with -Wimplicit-function-declaration made the whole situation a
lot clearer - why isn't this warning enabled by default ?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]