Page 1 of 1

atof code size

Posted: Fri Jun 08, 2012 10:15 pm
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

Re: atof code size

Posted: Fri Jun 08, 2012 10:31 pm
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

Re: atof code size

Posted: Sat Jun 09, 2012 6:53 am
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

Re: atof code size

Posted: Sat Jun 09, 2012 6:56 am
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.