Doubt about library functions in compilation

Hi everyone
A question is itching in my head.

When compiling any code using the arduino IDE, and this code includes a bilbiotca.
This included library has "n" functions, but in code I only use "n - x" functions.

When compiling, does the code generated to be written to the arduino contain all the functions from the library or only the functions called by the code, (and the calls by the functions I called)?

I think only the ones I called, (and the calls by the functions I called), but when in doubt, I ask everyone.

I don't know if I could be clear on my question.

Thanks.

RV mineirin

You can easily check this yourself:
Call an unused function (for testing) and compare the length of the compiled code before and after.

1 Like

I believe it's just the functions you call, directly or indirectly. Should be easy to test it though.

1 Like

its just the functions actually used.

But when in doubt check yourself ..........................

1 Like

Thinking about it some more, if the linker didn't drop unused functions, it would be a nightmare for anyone compiling for a low memory device. You would have people forking libraries left and right, trying to minimize the footprint for their needs, resulting in a confusing mess for anyone trying to get the functions required.

Tks for all

RV mineirin

Only the ones you have call, directly or indirectly, AND any virtual functions that "might" be called. (sigh.)

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.