This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize sprintf(buffer,"foo")
On Mon, Jun 23, 2003 at 04:07:18PM +0100, Joseph S. Myers wrote:
> On Mon, 23 Jun 2003, Jakub Jelinek wrote:
>
> > Then, if we have some way to find out at compile time the target platform
> > provides stpcpy in libc (dunno whether explicit stpcpy prototype would
> > be enough or whether we need some #pragma or whatever),
I doubt you would find any system that provides sprintf but not strcpy. I have
seen embedded systems that didn't bother providing sprintf, but they did
provide strcpy.
> We'd actually like also to know whether the target provides __stpcpy in
> libc since ISO C programs could redefine stpcpy.
Actually, ISO C programs cannot redefine strcpy in a hosted environment.
Programs that use ISO C features but are not strictly conforming can redefine
strcpy. If you want to be able to handle programs that redefine the library,
you probably should be using -fno-builtins.
> I'd like a general mechanism by which a libc header file can be included
> at the start of all compilations if it exists (and silently ignored if it
> doesn't), to get the definition of __STDC_ISO_10646__ (which describes
> libc features but must be available for the whole translation unit) right.
> Perhaps such a header could also contain pragmas like "#pragma GCC
> libc_provides stpcpy".
>
> (Such a header of course must _only_ have such macros and pragmas - it
> can't include any other glibc headers that test feature test macros, as
> those may be defined in the source file at any point before it includes
> standard headers.)
>
> --
> Joseph S. Myers
> jsm28@cam.ac.uk
--
Michael Meissner
email: gnu@the-meissners.org
http://www.the-meissners.org