Reputation: 10931
Library.h
void Foo1(void); // Unused
int Foo2(int, int); // Used
char Foo3(char); // Unused
main.c
// ...
#include "Library.h"
// ...
void main(void)
{
int ret;
// ...
ret = Foo2(3, 7);
// ...
}
I have a library file which has a lot of function definitions in it. Will the generated machine code size increase because of the unused library functions? Or will the compiler optimize the code by ignoring those unused functions?
IDE: MPLAB 8.43
Compiler: MCC18 3.34
PIC: 18F2550
Upvotes: 3
Views: 291
Reputation: 1
For C18 member in lib is .o - so if your link requires one function from a member the whole (all functions from) .o is included in final bin/hex code.
Upvotes: 0
Reputation: 224972
Upvotes: 2