Go Down

Topic: Quick question on compilers (Read 570 times) previous topic - next topic

tweedius

When you compile a piece of code that has files included in it.  What parts get compiled?  For instance, if I've created a library to take advantage of the full function of my MCP23017 I/O expander but I never call a specific function that I've coded in the header file, does that get compiled with everything and thus added onto the chip taking up some of the valuable programming space?  I'm familiar with asm and such, but compilers are a little out of my league.  Any thoughts?  If this has been asked before, any links?

Thanks for your time :)

-Tweed

Coding Badly

Quote
When you compile a piece of code that has files included in it.  What parts get compiled?


Everything fed to the compiler gets compiled into an "object file" (dot-obj file).

Quote
For instance, if I've created a library to take advantage of the full function of my MCP23017 I/O expander but I never call a specific function that I've coded in the header file, does that get compiled with everything


Yes.  However, the linker removes most "dead code".  From what you've described it is very likely that the unreferenced function will be removed by the linker.

Go Up