What are Redlib and Newlib?

cancel
Showing results for 
Search instead for 
Did you mean: 

What are Redlib and Newlib?

16,292 Views
lpcware-support
Senior Contributor I

The LPCXpresso IDE is shipped with three C libraries:

  • Newlib - GNU C library
  • NewlibNano - a version of the GNU C library optimized for embedded.
  • Redlib - Our own (non-GNU) ISO C90 standard C library, with some C99 extensions.

By default, LPCXpresso will use the Redlib (family of) libraries for C projects and the Newlib (family of) libraries for C++ projects. Newlib provides complete C99 and C++ library support at the expense of a larger (in some cases, much larger) code size in your application. If you prefer a smaller application and don't need the additional functionality of the C99 or C++ libraries, you should use Redlib, which can can produce much smaller applications.

Redlib extensions to C90

Redlib does implement a number of extensions to the C90 C library specification, including some from the C99 specification. These include

    • Single precision math functions
      • Single precision implementations of some of the math.h functions such as sinf() and cosf() are provided.
    • stdbool.h
      • An implementation of the C99 stdbool.h header is provided.
    • itoa
      • itoa() is non-standard library function which is provided in many other toolchains to convert an integer to a string. To ease porting, an implementation of this function is provided, accessible via stdlib.h. For more details, please see the FAQ "itoa() and uitoa() in Redlib".

Library variants

Each C library is also provided in three variants (None, Nohost and Semihost).

For details please see the FAQ "What are none, nohost and semihost libraries?".

For details on how to switch the selected C library, please see the FAQ "Switching the selected C library".

Labels (1)
2 Replies

4,157 Views
m4l490n
Contributor V

And what would be the difference (advantage?) between Redlib and Newlibnano?

0 Kudos

4,154 Views
ErichS
Senior Contributor III

In a nutshell:

- RedLIb is a NXP proprietary compact library implementation: not a full implementation (e.g. does not support C++, or gcov and gprof)

- NewLib-Nano is a more compact library implementation than NewLib, aiming for code size instead of speed

As long as you don't use the standard library functions (printf, malloc, etc) it does not really matter. If your concern is minimal footprint and you don't care about the C (or C++) standard implementation, you might be best with RedLib. If you are concerned about the C library standard, go with newlib or newlib-nano. If you need speed but don't care much about RAM and FLASH usage and want the full blown thing or want to use C++: go with newlib, otherwise go with newlib-nano.

Personally I avoid using most of the C library functions anyway, but they still can be useful. Otherwise I prefer using newlib-nano as I can rebuild it from sources if needed.

I hope this helps,

Erich