I tend to leave old code around as comments until I am sure that my current version is stable. Just the way I like working. I am concerned that I may be unnecessarily bloating up my sketches.

Do comments occupy space in an Arduino IDE compiled C++ sketch for Arduino (Nano, Uno)? Is it correct to suppose that the behavior would be the same for NodeMCU?

  • 2
    you can determine that by compiling two identical sketches, one of which has a huge amount of comments
    – jsotola
    Sep 11, 2019 at 19:54
  • 1
    Not related to your question but... you should learn to use version control, and use comments for... commenting the code! Sep 11, 2019 at 20:26
  • Unrelated, unhelpful, unasked for and... mistaken. One is often wrong when guessing with little or no information to base one's assumptions upon. I am talking about in between versions, as is clearly stated in the question.
    – tony gil
    Sep 12, 2019 at 0:02
  • What's unhelpful, unasked for and mistaken? Edgar's comment about source control is a very good suggestion. (Keeping your old code in the file as comments is superfluous if you use version control.)
    – Duncan C
    Sep 12, 2019 at 0:50

2 Answers 2


The C/C++ processor (which processes only the #define & #include statements) is the first stage of the compilation process. It runs before the compiler does and strips out everything that isn't code. The compiler will never see your comments.


No. Comments don’t take up any space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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