Next Previous Contents

## 2. ISO C compatible library

The C library contains a large subset of the ISO C library. Functions are usually missing in areas, where there is no support on typical 6502 systems. Wide character sets are an example for this.

I will not go into detail about the ISO functions. If a function is not mentioned here explicitly, expect it to be available and to behave as defined in the C standard.

Functions that are not available:

- `tmpfile/tmpnam`
- `system`
- All functions that handle floating point numbers in some manner.
- The `ldiv` function (cc65 is currently not able to return structs with a size not equal to 1, 2 or 4 bytes by value).
- All functions handling wide character strings.
- Signals and all related functions (having `SIGSEGV` would be cool:-)
- `setbuf/setvbuf`

Functions not available on all supported systems:

- `fopen/fread/fwrite/fclose/fputs/fgets/fscanf`: The functions are built on open/read/write/close. These latter functions are not available on all systems.
- `ftell/fseek/fgetpos/fsetpos`: Support depends on the capabilities of the target machine.
- `rename/remove/rewind`: Support depends on the capabilities of the target machine.
- `time`: Since many of the supported systems do not have a real time clock, which means that the `time` function is not available. Please note that the other functions from `time.h` are available.

Functions that are limited in any way:

- `strcspn/strpbrk/strspn`: These functions have a length limitation of 256 for the second string argument. Since this string gives a character set, and there are only 256 distinct characters, this shouldn't be a problem.
- `getenv`: Since there is no such thing as an environment on all supported systems, the `getenv` function will always return a `NULL` pointer.
- `locale`: There is no other locale than the "C" locale. The native locale is identical to the "C" locale.

In addition to these limitations, some more functions are limited if inlined versions are requested by using -Os:

- The `strlen` function only works for strings with a maximum length of 255 characters.
- The `isxxx` character classification functions from `<ctype.h>` will give unpredictable results if the argument is not in character range (0..255). This limitation may be removed by #undef'ing the function name (when using `-Os`, the functions are actually macros that expand to inline assembler code, but the real functions are still available if the macro definition is removed).

Next Previous Contents