Minimizing code size

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Minimizing code size

1,143 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by joe912 on Fri Apr 16 07:27:22 MST 2010
so i have a project where i need to compute a value using a "sin()"
so i include "math.h" and then put the sin function in my code. 
however this increases the code size by roughly 10K

so im assuming that when i use a function from math.h it is including all of the functions.
is there a way i can tell the compiler to remove the unused functions?
0 项奖励
回复
5 回复数

1,132 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fpg on Fri Nov 25 11:54:40 MST 2011

Quote: fpg
I'm planning to remove unused codes right now. Do these problems still exist?



Oh I see now it is the new default...
0 项奖励
回复

1,132 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fpg on Fri Nov 25 11:50:48 MST 2011

Quote: CodeRedSupport
If you use --gc-sections on debug builds, you can still debug, but you will occasionally see some odd things, such as being unable to step into functions, or being unable to display some variables. We are working to resolve this issue.




I'm planning to remove unused codes right now. Do these problems still exist?
0 项奖励
回复

1,132 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Apr 16 10:19:17 MST 2010
If you use --gc-sections on debug builds, you can still debug, but you will occasionally see some odd things, such as being unable to step into functions, or being unable to display some variables. We are working to resolve this issue.
0 项奖励
回复

1,132 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by joe912 on Fri Apr 16 08:46:41 MST 2010
perfect thank you.

by problems what do you mean?

unable to debug?
0 项奖励
回复

1,132 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Apr 16 07:41:21 MST 2010
You want to use the "--gc-sections" option in the linker. This is the default for Releae builds, but is not used for Debug builds as it can cause some problems when debugging.

To set this option, select your project in Project Explorer and then:
Project->Properties
Expand C/C++ Build and then click on Settings
Under MCU Linker, select Miscellaneous
Under "Other options" press the button with the green "+"
and add --gc-sections
OK

When you are done, the dialog will look something like screenshot attachment
0 项奖励
回复