Keil MicroLib vs Standard C Library

Beginners using Keil to learn microcontrollers often enable the built-in MicroLib when using the serial printf for output:

Keil MicroLib vs Standard C LibraryRecently, I saw readers discussing the topic of Keil’s MicroLib and the standard C library, so I would like to share some related content.

What is MicroLib?

MicroLib is a highly optimized library for ARM-based embedded applications written in C.

Compared to the standard C library that comes with the ARM Compiler toolchain, MicroLib has a significant advantage in code size.Keil MicroLib vs Standard C LibraryThe above image shows a performance benchmark test code, which indicates that the MicroLib has significantly less code size under different cores.Supplement: The standard C library is commonly used, including libraries such as <stdio.h>, <stdlib.h>, <string.h>, <math.h>, <error.h>, <assert.h>, etc. Under these files, there are many various library functions, such as printf(), malloc(), memcpy(), strncpy(), etc.

Differences Between MicroLib and Standard C Library

Because ARM embedded systems typically have relatively small storage (code) resources, engineers have optimized the standard C library for ARM embedded systems to reduce code size.

Optimizing the standard library will inevitably lead to some differences. Here are a few main differences:

1. Smaller code (data) size (compared to the above image);

2. Lacks some less commonly used standard library functions, such as file I/O library functions;

3. The MicroLib maximally optimizes code size, which may result in some library code running slower;

4. Can be used in systems like RTOS, but not supported in systems like Windows.

Conclusion

MicroLib functions are also a type of function, and many of its library function prototypes can be found online. If you have special requirements, you can modify the prototypes based on the library functions.

For example, if your project has been validated and finds that the code size or running speed of MicroLib is not ideal, you can modify the prototype functions yourself.Of course, modifying prototype functions is only recommended as a last resort. It is generally advisable to use MicroLib directly, as libraries that have been validated multiple times by others have a lower probability of bugs.Keil MicroLib vs Standard C Library

END

Source: strongerHuangCopyright belongs to the original author. If there is any infringement, please contact for deletion.Recommended ReadingIs CAN bus harder than UART serial?Sharing an open-source serial tool, it’s amazing!In just three months, ZhiHuiJun’s startup project has received three rounds of financing.

→ Follow for updates ←

Leave a Comment