KurtE
Senior Member+
Normally I always have one verbose output for compilation.
And show all compiler warnings, which for those who do not know about these options you can set in the Arduino preferences dialog.
And I normally try to make sure to remove all compiler warnings... However from time to time a few sneak in...
And right now I am seeing a few showing up in a sketch I am working on and I am in the process or removing them.
Sometimes the warnings are not always obvious, example in ST7735 we have code that compiles two unsigned variables and compares to another unsigned variable, and we have a warning:
turns out that both: _dma_cnt_sub_frames_per_frame and _dma_buffer_size are uint16_t
and _count_pixels is uint32_t
Fix in this case is I cast the result from the multiply to uint32_t...
In USBHost_t36 we have some code that looks like:
And it gives us a warning like: warning: 'val' may be used uninitialized in this function
Which is wrong as val will set in all 4 possible cases of a tag & 3...
I obviously can fix several different ways, like: add default: t one of the items in first switch, could just set val=0 when we define the variable and optionally not set it in case 0...
Again I can and will remove these warnings, but thought I would post this as a reminder to myself (and maybe others) to be on the look out for warning in the source code that we ship with Teensyduino .
And show all compiler warnings, which for those who do not know about these options you can set in the Arduino preferences dialog.
And I normally try to make sure to remove all compiler warnings... However from time to time a few sneak in...
And right now I am seeing a few showing up in a sketch I am working on and I am in the process or removing them.
Sometimes the warnings are not always obvious, example in ST7735 we have code that compiles two unsigned variables and compares to another unsigned variable, and we have a warning:
Code:
yyy:19: warning: comparison between signed and unsigned integer expressions
while ((_dma_cnt_sub_frames_per_frame * _dma_buffer_size) != (_count_pixels)) {
^
and _count_pixels is uint32_t
Fix in this case is I cast the result from the multiply to uint32_t...
In USBHost_t36 we have some code that looks like:
Code:
uint8_t tag = *p;
switch (tag & 0x03) { // Short Item data
case 0: val = 0;
p++;
break;
case 1: val = p[1];
p += 2;
break;
case 2: val = p[1] | (p[2] << 8);
p += 3;
break;
case 3: val = p[1] | (p[2] << 8) | (p[3] << 16) | (p[4] << 24);
p += 5;
break;
}
if (p > end) break;
switch (tag & 0xFC) {
case 0x84: // Report ID (global)
break;
case 0x04: // Usage Page (global)
[COLOR="#FF0000"]usage_page = va[/COLOR]l;
break;
Which is wrong as val will set in all 4 possible cases of a tag & 3...
I obviously can fix several different ways, like: add default: t one of the items in first switch, could just set val=0 when we define the variable and optionally not set it in case 0...
Again I can and will remove these warnings, but thought I would post this as a reminder to myself (and maybe others) to be on the look out for warning in the source code that we ship with Teensyduino .