gcc bug: complaint on %c for strftime
Andries.Brouwer@cwi.nl
Andries.Brouwer@cwi.nl
Tue Nov 26 09:53:00 GMT 2002
Various versions of gcc such as gcc 3.2 complain
about strftime(,,"%c",) with the reaction
warning: `%c' yields only last 2 digits of year in some locales
This is a bug.
%c is described as: the preferred date and time representation
for the current locale. How can you give an error message for
that? What is the programmer to do? Choose a non-preferred
representation?
The docs for Wall say:
-Wall All of the above `-W' options combined. These are
all the options which pertain to usage that we recÂ
ommend avoiding and that we believe is easy to
avoid, even in conjunction with macros.
so %c should be easy to avoid. I have no idea how.
But the warning is easy to avoid using silliness like
/*
* Stop extremely silly gcc complaint on %c:
* warning: `%c' yields only last 2 digits of year in some locales
*/
static void
my_strftime(char *buf, size_t len, const char *fmt, const struct tm *tm) {
strftime(buf, len, fmt, tm);
}
[this is what I do now in util-linux, but I can hardly imagine
that this is what you hoped to achieve].
Andries
More information about the Gcc
mailing list