News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

curious warning

Started by jullien, August 16, 2014, 03:21:35 PM

Previous topic - Next topic

jullien

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

frankie

#1
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.   :(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

jullien

Ooops I ment -W2.
-W4 is the max warning for Microsoft, sorry!