Author Topic: Changing from warning level -W1 to -W2  (Read 1851 times)


  • Guest
Changing from warning level -W1 to -W2
« on: March 23, 2015, 03:22:16 am »
I change my warnings level from -W1 to -W2. After using the -W1 warning, the -W2 setting detected unused return values, unused parameters, mismatched data types, and suggestions that 'size_t' should be used for loop variables (instead of the 'int' values I was using).

I was able to stop all of the warnings. For unused return values and unused parameters I used dummy (useless) global variables (for example I used 'ix' for 'int' and 'UINTx' for 'UINT'). I stopped the warnings about mismatched data types by using type casts. The warnings suggesting the usage of 'size_t' for loop variables was harder to solve. Several were solved by changing 'int' to 'unsigned int'. I had to use 'size_t' in some places and some of those resulted in new warnings that 'int' was expected but 'unsigned long long int' was found. Again I used casts to stop those warnings.

The bottom line is that -W1 warning were often very helpful by pointing out very real problems with my code. The -W2 warnings were not quite as helpful but perhaps here and there they could be. I suppose my next step is to use lint. Any suggestions?