This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc bug: complaint on %c for strftime
- From: Andries dot Brouwer at cwi dot nl
- To: jsm28 at cam dot ac dot uk
- Cc: gcc-gnats at gcc dot gnu dot org, gcc at gcc dot gnu dot org, proski at gnu dot org
- Date: Tue, 26 Nov 2002 13:19:39 +0100 (MET)
- Subject: gcc bug: complaint on %c for strftime
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