I'm using a couple of the "include" type files that add considerably to my final code size. The USART module adds about 2K to my program byte size, for example, and over 200 variable bytes.
Does the compiler recognise that a large portion of an include file is never used/referenced and discard that code or is everything compiled regardless?
If the latter I suppose the answer is to make one's own library from the provided include file, and only keep the routines actually used, is this right?
Comiler discards unused code (subs)?
Moderators: David Barker, Jerry Messina
Comiler discards unused code (subs)?
Aresby
Swordfish & PIC Newbie
Swordfish & PIC Newbie
-
- Swordfish Developer
- Posts: 1473
- Joined: Fri Jan 30, 2009 6:27 pm
- Location: US
It discards any unused/unreferenced routines and variables, so you don't have to worry about them using up space.
The usart module itself probably isn't adding all that much. Do you use a lot of string data? What you may be seeing is all the overhead associated with them.
SF has very powerful string handling capability, esp compared to something like C. You can mix ram and rom strings, perform operations on them, etc. All of that comes at a high cost, however. If you look behind the scenes, you see a lot of string copying and temp strings used to get all that flexibility.
There are ways around that, but you have to be willing to do a lot of work yourself.
The usart module itself probably isn't adding all that much. Do you use a lot of string data? What you may be seeing is all the overhead associated with them.
SF has very powerful string handling capability, esp compared to something like C. You can mix ram and rom strings, perform operations on them, etc. All of that comes at a high cost, however. If you look behind the scenes, you see a lot of string copying and temp strings used to get all that flexibility.
There are ways around that, but you have to be willing to do a lot of work yourself.