Pelles C forum

Pelles C => Bug reports => Topic started by: jullien on August 16, 2014, 03:21:35 PM

Title: curious warning
Post by: jullien on August 16, 2014, 03:21:35 PM
With -W4, sometimes (not always) I get:
xxx.c(1799): warning #2804: Consider changing type to 'size_t' for loop variable 'i'.

While I use for loop using int like:

   int    i;

   for (i = 0 ; i < n ; ++i) {
      res = foo( res );
   }
...


Strictly speaking, it is not of course a bug, but I wonder why this warning appears.
What is the added value? I doubt using size_t makes code faster with all C compilers for simple loops.
size_t may not be the fastest integer type. I would use int_fastxx_t for example which is defined in stdint.h

Explanation is welcome.

Christian
Title: Re: curious warning
Post by: frankie on August 16, 2014, 04:05:58 PM
Quote from: jullien on August 16, 2014, 03:21:35 PM
With -W4, sometimes (not always) I get:

-W4 ?   ???
There should be no such warning level in PellesC.   :(
Title: Re: curious warning
Post by: jullien on August 17, 2014, 07:31:24 AM
Ooops I ment -W2.
-W4 is the max warning for Microsoft, sorry!