This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: size_t printf warnings and preprocessor


Marc Espie <espie@schutzenberger.liafa.jussieu.fr> writes:

> On Thu, Jul 12, 2001 at 05:48:52PM +0200, Andreas Jaeger wrote:
>> Marc Espie <espie@quatramaran.ens.fr> writes:
>> 
>> > I would love to get size_t warnings for printf out of gcc.
>> > I've already noticed that 3.0 is much better at following typeinfo than
>> > 2.95 used to.
>> > 
>> > I would like to have a switch such that 
>> > size_t var;
>> > printf(format, var);
>> > 
>> > invariably ends in an error, as there can't be a single format that works
>> > with size_t.
>> 
>> "%z" is specified by ISO C 99 for size_t.  So what's wrong with printf
>> ("%z\n", var) ?
>> 
>> Sorry, I'm lost with your proposal.
> 
> Nothing is wrong, I don't have the C99 proposal with me... :)
> 
> Okay, what I'm proposing still makes sense in the legacy case, for people
> who have written code before %z and who would like it checked.
> 
> Also, in pedantic C99 mode, do we warn when size_t is used without %z ?

Now I get it - you do it the other way round.  You want to allow
size_t only with %z and forbid e.g. "%ld", var or even "%ld",(long)var.

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]