atof code size

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

atof code size

Post by hazelnusse »

I've implemented some commands with the ChibiOS shell, one of which I would like to take a floating point number. When I use atof() to convert this string to a double, my code size increases by 13kb. This seems like a lot. Am I doing something wrong or is there a better way to do this?

Thanks,
Luke
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: atof code size

Post by Tectu »

It's known that string manipulating functions like itoa, atio, sprintf and similar take a lot of space.

When you just need for example itoa(), wich does not need to support all it's features form the known string.h library, you can google them.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: atof code size

Post by Giovanni »

Tectu is right, probably that function has dependencies on a lot of FP-related code in the C library. Consider writing your own implementation if you use just that FP function.

Giovanni
DrunkenDonkey
Posts: 124
Joined: Sun Aug 28, 2011 5:16 pm

Re: atof code size

Post by DrunkenDonkey »

While on the topic, is there a way to really make sure you are not using any of the std lib/newlib/whatever functions? It is better to get a linker error, go implement your own than link something huge.
Post Reply