strftime's %c warning?

Marc Olzheim marcolz at stack.nl
Thu Oct 9 09:16:51 UTC 2008


On Wed, Oct 08, 2008 at 10:20:00PM +0200, Ivan Voras wrote:
> I'm trying to use the %c formatter in strftime(3), documented as:
> 
> "
>      %c    is replaced by national representation of time and date.
> "
> 
> ... which looks useful, except that in code in which WFORMAT is defined
> as "1" I get this error:
> 
> str.c: In function 'ltime':
> str.c:141: warning: '%c' yields only last 2 digits of year in some
> locales on non-BSD systems
> *** Error code 1
> 
> Since the code I'm developing is definitely BSD-only (patch to pkg_*
> infrastructure), should I:
> 
> a) stop using locale-based %c and choose my own date/time format
> b) remove WFORMAT from the Makefile?
> 
> The same warning/error is generated by %x and %X, and %+ described in
> the strftime man page isn't recognized.

Yes. In FreeBSD 4.x, gcc was patched not to warn about these, so
compiling with -Werror was possible even when using this. Since FreeBSD
5.x, this patch wasn't applied anymore.

If you only want it to compile on your own system with -Werror, you can
use this patch (and probably adapt it to %c, %x and %X as well):
http://www.stack.nl/~marcolz/FreeBSD/gcc-strftime-format-freebsd7.patch.txt

Marc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20081009/3458e1c9/attachment.pgp


More information about the freebsd-hackers mailing list