Skip to main content
Arduino

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Program size optimization

I am trying to spare a few bytes of program size. I faced a problem which I cannot understand and I hope somebody will help.

Look at this empty sketch, pleas. It takes just 444 bytes:

void setup()
{
}
void loop()
{
}

However, this one – 1332 bytes already!

void f() {
 Serial.println(1);
}
void setup()
{
}
void loop()
{
}

Why? It is supposed that function f() will be cut-off during the linkage stage. But it is not. And what can I do to cut such things off, since they are not used in the code?

Answer*

Draft saved
Draft discarded
Cancel
2
  • You might like to add that the missing static forces the compiler to include f() in the first place. All other stuff is then pulled in by this. Commented Feb 25, 2021 at 12:03
  • @thebusybee: Right, I edited my answer. Commented Feb 25, 2021 at 14:00

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /