在使用M4的FPU的时候,需要注意不要用mdk的微库。这是因为M4的FPU是符合IEEE754标准的浮点运算单元。微库是不兼容IEEE754浮点表示的标准的。微库是MDK提供的一个库,对C标准库进行了深度优化,用微库得到的代码会更小,并且也会带来一些问题,下面是微库和标准库之间的主要差异:8 { R1 K& K/ g( Q# b/ Z# ~ ~* k- S Microlib is not compliant with the ISO C library standard. Some ISO features are not supported and others have less functionality.7 O. g% \3 x# m& X( B1 Z( @ : m! f; W# t8 ~. A8 E+ |9 T! B2 o& D+ N Microlib is not compliant with the IEEE 754 standard for binary floating-point arithmetic.! ?6 ^8 w% I: v Microlib is highly optimized for small code size., H6 u* E/ M, \* H5 W 4 B; ~3 q/ H' C5 p6 h: W- z$ s Locales are not configurable. The default C locale is the only one available.. w4 W! T/ b6 v1 ^ ( t! K0 ]; v, S; e& Q' R0 {$ \ main() must not be declared to take arguments and must not return. 0 \& z$ y" ?. X/ t1 J8 g& _: { Microlib provides limited support for C99 functions. Microlib does not support C++. 8 A% _8 R8 B2 E; x8 m, f% [2 S Microlib does not support operating system functions. Microlib does not support position-independent code. 8 ?. h/ Z1 f: Z+ C0 F Microlib does not provide mutex locks to guard against code that is not thread safe. Y4 J/ }/ c7 x Microlib does not support wide characters or multibyte strings. Microlib does not support selectable one or two region memory models as the standard library (stdlib) does. Microlib provides only the two region memory model with separate stack and heap regions., R# g. A# c" ?( F Microlib does not support the bit-aligned memory functions _membitcpy[b|h|w][b|l]() and membitmove[b|h|w][b|l]().; A/ Z. T: y' A6 `% A Microlib can be used with either --fpmode=std or --fpmode=fast.1 Q% y$ d4 \9 t7 q. ~5 B3 K4 R; D# j The level of ANSI C stdio support that is provided can be controlled with #pragma import(__use_full_stdio).8 x* W) P s$ b5 t! ] #pragma import(__use_smaller_memcpy) selects a smaller, but slower, version of memcpy(). , I( E5 k6 o5 J+ y+ \' X. K setvbuf() and setbuf() always fail because all streams are unbuffered.7 p/ k1 Y3 X# h+ j# q5 f: _5 k, O ; b Z W" d( K feof() and ferror() always return 0 because the error and EOF indicators are not supported. : h/ e- b/ U/ ~& R7 e) e) Z) [ 差异中需要注意的有,微库不兼容IEEE754,不支持c++,不支持流缓冲,不支持操作系统函数(移植的操作系统还是支持的,不过我还是不推荐),不提供互斥锁来防止非线程安全的代码,memcpy函数会变慢,不支持宽字符。所以再有以上应用的时候,尽量不要用微库。 |