I'm working on a program composed by several classes.
I reduced the size of a single class of (more or less) one hundred lines (4kb of stuff)
I expected a smaller sketch but surprisingly it is increased in size (few bytes).

How is it possible?It's something about the compiler?

  • if it wasn't using those 100 lines anyway, you won't save anything... – dandavis Mar 23 '17 at 18:07

A compiler translates c/cpp to target assembly language.

To keep it short, some c/cpp language statements or keywords can be used to shorten the code (in c/cpp)... but the mechanics behind all that to translate to assembly can generate more instructions than you thought.

It would maybe be easier to explain if you put some example...

  • Arduino is C++ not C. – gre_gor Mar 23 '17 at 17:26
  • yep, true, thanks for pointing that out, i'll correct that (yet, you can code c libraries if you need)... and the generated assembly is even worse! – SMFSW Mar 23 '17 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.