Go Down

Topic: possible problem in BlinkWithoutDelay regarding constants (Read 1 time) previous topic - next topic

chopperdave

Thank you for clarifying this for me.

I'm pretty clear on what's happening, but it seems like a major pitfall for beginners.

In my opinion it would be an improvement for the compiler to say "Hey, the result of your arithmetic overflowed.  Is that what you meant to do?"

Again, thank you for helping me understand.

Nick Gammon


In my opinion it would be an improvement for the compiler to say "Hey, the result of your arithmetic overflowed.  Is that what you meant to do?"


Turn on verbose compilation and you get exactly that:

Code: [Select]

sketch_aug03a.cpp:4: warning: integer overflow in expression


Code to reproduce:

Code: [Select]

long interval = (100*1000);
void setup () {}
void loop () {}

dgerman

IMHO a warning should be displayed without Verbose compilation output.

With  verbose set so many messages are output that the final status of the output window is filled with
...avr-ar rcs ...core.a ...*.c.o
"
"
...avr-gcc...
...avr-objcopy... elf ... epp
...avr-objcopy... elf ... hex
The final
Binary sketch size: 466 bytes (of a 32,256 byte maximum)
looks good.

The warning is scrolled off

Not user friendly.

Nick Gammon

I agree, personally. However I believe that some libraries spew out warnings which may be confusing to beginners, even if there is nothing wrong with their code.

Go Up