I was taught in my introduction to C class that comments were ignored. So I didn’t really care if I wrote a lot of comments. However, now I am at that step where I would have to upload code into a microprocessor. I’m assuming comments are still comments.. but all code takes up space. Does this matter significantly in regards to memory of the microprocessor? Am I assuming that because comments are ignored, that means that the microprocessor won’t spend any cycles looking at it? Or should I typically have the only necessary amount? This might be a stupid question, but I don’t know the answer off the top of my head.. :X Thanks for your insight.
Share
If you’re uploading the raw C code (which I don’t think you’re doing), then yes, the comments would take up space because the raw C code file would be bigger. However, if you’re uploading the compiled code (which I do think you’re doing), it shouldn’t make a difference. During compilation the compiler should strip out all of the comments, and the code shouldn’t be any bigger with comments than without.
That said, someone could build an evil compiler that did use more space for code with lots of comments in it, but no one actually does this; it would be impossible to market. 🙂