This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: support for %m format argument to printf?
- From: Richard Earnshaw <rearnsha at gcc dot gnu dot org>
- To: Jeremy Elson <jelson at cs dot ucla dot edu>
- Cc: newlib at sources dot redhat dot com
- Date: Fri, 29 Oct 2004 10:54:27 +0100
- Subject: Re: support for %m format argument to printf?
- Organization: GNU
- References: <E1CNKws-0000Kz-ID@concorde.cs.ucla.edu>
On Fri, 2004-10-29 at 01:48, Jeremy Elson wrote:
> Hi,
>
> Gnu C allows you to specify "%m" in printf format strings; newlib
> doesn't. Is there any plan to add support? If not, I can work on a
> patch.
>
Ugg! I hope not. Not a good idea for space-conscious environments.
> If you're not familiar with it -- Gnu C lets you substitute %m for
> strerror(errno). It's similar to using perror(), except that you can
> construct more meaningful error messages, e.g.:
>
> printf("couldn't open %s: %m", filename);
>
> I'm porting software that extensively uses this idiom to newlib.
The problem is that this will cause the entire error strings table to be
unconditionally loaded into every image that needs printf (because the
linker can't tell which subsystems of printf are really needed and only
link those).
It's not a major issue in a shared libc environment, but it is in a
statically linked one.
R.