Follow+Star Public Account, don’t miss out on exciting content
Author | strongerHuang
WeChat Public Account | strongerHuang
Beginners use Keil to learn microcontrollers, and when using serial printf for output, they usually enable the built-in MicroLib:
Recently, I saw readers discussing the topic of Keil’s MicroLib and the standard C library, so today I will share some related content.
MicroLib is a highly optimized library for ARM 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.
The above image shows a performance benchmark test code, which indicates that the MicroLib has significantly less code size across different cores.
The C standard library is something we often call, such as: <stdio.h>, <stdlib.h>, <string.h>, <math.h>, <error.h>, <assert.h>, and other library files.
Under these files, there are many various library functions, such as: printf(), malloc(), memcpy(), strncpy(), etc.
Differences Between MicroLib and Standard C Library
Since ARM embedded systems usually have relatively small storage (code) resources, engineers optimize the standard C library for ARM embedded systems to reduce code size while still using standard functions.
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. Missing some less commonly used standard library functions, such as file I/O library functions.
3. MicroLib optimizes code size to the maximum extent, which may result in some library code running slower.
4. Can be used in systems like RTOS but not supported in systems like Windows.
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 function prototypes based on the library functions.
For example: If your project has been verified 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 usually suggested to use MicroLib directly, as libraries that have been verified by others have a lower probability of bugs.
———— END ————

● Column “Embedded Tools”
● Column “Embedded Development”
● Column “Keil Tutorial”
● Selected Tutorials from Embedded Column
Follow the public account and reply “Join Group” to join the technical exchange group according to the rules, reply “1024” to see more content.

Click “Read the Original” to see more shares.