PDCLib might fit your needs. It's still incomplete though, and probably in need of a lot more real-world testing. Its author goes by DevSolar here on SO.
PDCLib might fit your needs. It's still incomplete, though, and probably in need of a lot more real-world testing. Its author goes by DevSolar here on SO.
You can check out the LGPL µClibc, which is supposed to be close to glibc but much more suited to embedded systems. It also has a page referencing other open source C libraries, including newlib and eCos, which may be more suited for non-Linux environments.
– GT. Feb 7 at 13:35 Nope. See my comment on the original question.
– R.. Feb 7 at 19:02.
I use newlib on my Cortex_M3 with 32kB RAM, and to eliminate the malloc() you can use siprintf() or sniprintf(). Pro: No more calls to malloc(). Con: It does not suport formatting float and double, and is not really portable this way.
If you use newlib and do not implement the sbrk syscall, then any function you use that requires malloc will generate a linker error, which will prevent you from inadvertently using a call that requires dynamic memory . So I would suggest that you do that, and then simply avoid those functions that cause the linker error. You can modify or override any library functions you do not wish to use.
Printf() is not good for small embedded realtime systems! Actually it is worse than malloc in many ways. Variable argument lists, very complex formatting, float number support when you don't need it etc etc.Printf() comes with an enormous overhead, and the compiler will not be able to reduce it, as every parameter passed to it is evaluated in runtime.Printf() is perhaps ok for hobbyists and beginners still learning C.
But if you are a professional programmer, you really ought to write your own serial monitor / LCD routines. You will dramatically improve the program performance and flash consumption.
1 Though technically not an answer, I liked it. – Amigable Clark Kant Feb 7 at 14:03 It is an answer. For a small embedded realtime system, you shouldn't be using libraries stdio and stdlib in the first place!
MISRA-C bans stdio entirely, for example. – Lundin Feb 7 at 14:18 It depends ... I would never call printf() from a real time context, but I don't see any big problems using printf() in non time critial tasks. Calling malloc() should be avoided as much as possible because task creation needs malloc() for the per-task stack frame, and heap fragmentation can quickly lead to OOM situations.It is common to configure freertos with malloc(), but without a functional free() because frequent memory allocation/deallocations on systems with very little memory is considered too "risky".
– GT. Feb 7 at 14:31 6 There is nothing wrong with using printf in embedded systems. There's something wrong with printf implementations that call malloc and do all sorts of useless things.
A simple printf implementation without floating point (or that ignores exactness issues when printing floating point) and without POSIX i18n %n$ argument specifiers, can be implemented in about 2k of code, and allows the calling application to be much smaller and simpler than if it had to duplicate printf-like functionality all over the place. – R.. Feb 7 at 19:00 1 @Lundin: As Chris said, there's a big range of embedded systems, and often conditions like realtime (bounded-time operations) and failure-case-free are more important than extremely small memory size. I'd be a lot happier with an embedded device that uses 1 MB of memory but always works because I know where allocations take place than a device that "normally" uses 128 kB and has 256 kB of physical memory, but no strict bounds on usage and fails to do its job when an allocation fails.
– R.. Feb 77 at 11:38.
I had similar needs and found that klibc fit it quite well. The only downside (for commercial use) is the GPL license. I have hacked a minimal version of it here.
This is even more limited PDCLib, and suitable if you just need a few basic functions such as printf and strtok. Compiles to just 4kB with all functions included.
1 OP is apparently not using Linux, so these Linux-based choices will not be very helpful.. – R.. Feb 7 at 19:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.