🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Göran Uddeborg Wed, 27 Nov 1996 00:00
Missing warnings in internationalized code.
#6098
Author: Göran Uddeborg
Date: Wed, 27 Nov 1996 00:00
51 lines
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.
Re: Missing warnings in internationalized code.
#6101
Author: Ulrich Drepper
Date: Wed, 27 Nov 1996 00:00
17 lines
1444 bytes
G=F6ran Uddeborg <uddeborg@carmen.se> writes:

> with the "-Wall" option to gcc, I get the following valuable warning
> message:
>=20
>     #.c: In function `main':
>     #.c:7: warning: too many arguments for format
>=20
> But when I add the gettext macro to this code:

This is already changed for gcc-2.8.

-- Uli
--------------.       drepper@cygnus.com  ,-.   Rubensstrasse 5
Ulrich Drepper \    ,--------------------'   \  76149 Karlsruhe/Germany
Cygnus Support  `--'  drepper@gnu.ai.mit.edu  `------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads