Choosing the type of Index Variables
<p>We use Integer type represent index variables most of the time. But in some situations, we're forced to choose </p>

<pre><code>std::vector&lt;int&gt; vec;
....

for(int i = 0; i &lt; vec.size(); ++i)
....
</code></pre>

<p>This will cause the compiler to raise the warning that mixed use of signed/unsigned variables. if I make the index variable as <code>for( size_t i = 0; i &lt; vec.size(); i++ )</code>, (or an <code>unsigned int</code> )it will sort out the issues.</p>

<p>When it come more specific to use windows types, most of the Windows APIs are dealing with DWORD (which typedef-ed as unsigned long).</p>

<p>So when I use similar iteration, will again cause the same warning. Now if I rewrite it as </p>

<pre><code>DWORD dwCount;
....

for(DWORD i = 0; i &lt; dwCount; ++i)
....
</code></pre>

<p>I find this a bit weird. It might be the problem withe perceptions. </p>

<p>I agree that we are supposed to use the same type of index variable to avoid the range problems can happen with the index variables. For e.g if we're using </p>

<pre><code>_int64 i64Count; // 
....

for(_int64 i = 0; i &lt; i64Count; ++i)
....
</code></pre>

<p>But in the case of DWORD, or unsigned integers, are there any problems in rewriting it as </p>

<pre><code>for(int i = 0; (size_t)i &lt; vec.size(); ++i)
</code></pre>

<p>How most of the people are working with similar issues?</p>
