NO

Author Topic: curious warning  (Read 2595 times)

jullien

  • Guest
curious warning
« 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

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: curious warning
« Reply #1 on: August 16, 2014, 04:05:58 PM »
With -W4, sometimes (not always) I get:

-W4 ?   ???
There should be no such warning level in PellesC.   :(
« Last Edit: August 16, 2014, 04:34:38 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

jullien

  • Guest
Re: curious warning
« Reply #2 on: August 17, 2014, 07:31:24 AM »
Ooops I ment -W2.
-W4 is the max warning for Microsoft, sorry!