Cosmic UK Cosmic US Cosmic Germany Cosmic Italia Cosmic France

Cosmic Software Frequently Asked Questions

I would like to use printf or sprintf, but the code is too large for my available space. Are there smaller versions for simple applications?

According to ANSI and ISO standards, both printf and sprintf must support many different types, conversions and formatting options which together results in a substantial amount of code for an embedded application. The Cosmic integer only library helps reduce the size while still supporting all integral data types and format specifiers including the longs data type which is usually 32 bits. Cosmic also offers a reduced version sprintf and printf by removing support for longs and the associated conversion and format modifiers. You can significantly reduce the code size of both printf and sprintf by replacing the standard "cprint.o" module in the integer library with the simplified version available below. This version will support chars, integers, shorts and strings, but not longs and floats. It also supports the format modifiers %c, %o, %d, %x, %X, %u and %s. To use the simplified and smaller version of printf and sprintf simply download the source file for cprint.c below and add it to your application so that is is rebuilt with the same options as your application and then link cprint.o just before the integer library in your link command file. i.e.