Article View: gnu.gcc.bug
Article #6098Missing warnings in internationalized code.
From: Göran Uddeborg
Date: Wed, 27 Nov 1996 00:00
Date: Wed, 27 Nov 1996 00:00
51 lines
1976 bytes
1976 bytes
Configuration
=============
gcc 2.7.2
gettext 0.10
HP-UX 10.20
HP 9000/715
Problem
=======
After a program is internationalized, one looses gcc's check on the
format strings. E.g., if I compile this program:
#include <libintl.h>
#include <stdio.h>
#define _(String) gettext (String)
int main()
{
printf("apa",5);
return 0;
}
with the "-Wall" option to gcc, I get the following valuable warning
message:
#.c: In function `main':
#.c:7: warning: too many arguments for format
But when I add the gettext macro to this code:
#include <libintl.h>
#include <stdio.h>
#define _(String) gettext (String)
int main()
{
printf(_("apa"),5);
return 0;
}
gcc no longer gives me any warning about my mistake.
I fully realize why this happens. The format argument of printf is no
longer a constant string, so gcc don't know what the format will look
like at run time. But this is a very typical thing in an
internationalized program. Perhaps it would be worthwhile to add some
way to tell gcc it should ignore calls to gettext() for the purposes
of this warning check? When I make a translation, msgfmt will warn me
if I change the number or order of the format directives, so that part
of the process is taken care of.
Technical Details
Message-ID:
<199611271339.OAA01393@narsarsuaq.carmen.se>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 113d02,85e40e3bedb9d0c0,start X-Google-Attributes: gid113d02,public From: uddeborg@carmen.se (Göran Uddeborg) Subject: Missing warnings in internationalized code. Date: 1996/11/27 Message-ID: <199611271339.OAA01393@narsarsuaq.carmen.se> X-Deja-AN: 201033391 sender: bug-gcc-request@prep.ai.mit.edu content-type: text/plain; charset=US-ASCII x-gateway: relay7.UU.NET from bug-gcc to gnu.gcc.bug; Wed, 27 Nov 1996 08:40:41 EST x-url: http://www.carmen.se/~uddeborg/ mime-version: 1.0 (generated by tm-edit 7.85) newsgroups: gnu.gcc.bug