SLAA534A June 2013 – June 2020
The TI toolset defines the following constants for use with the stdio.h library:
#define _IOFBF 1
#define _IOLBF 2
#define _IONBF 4
#define BUFSIZ 256
#define EOF (-1)
#define FOPEN_MAX
#define FILENAME_MAX
#define TMP_MAX
#define L_tmpnam
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#define stdin &_ftable[0]
#define stdout &_ftable[1]
#define stderr &_ftable[2]
The FOPEN_MAX, FILENAME_MAX, TMP_MAX, and L_tmpnam values are actually minimum maxima. The library is free to provide support for more/larger values, but must at least provide the specified values.
Because the TI toolset defines stdout and stderr as &_ftable[1] and &_ftable[2], the size of FILE must be known to the implementation.
In the TI header files, stdin, stdout, and stderr expand to references into the array _ftable. To successfully interlink with such files, any other implementations need to implement the FILE array with exactly that name. The MSP430 EABI does not have a "compatibility mode" (like the mode in the ARM EABI) in which stdin, stdout, and stderr are link-time symbols, not macros. The lack of a compatibility mode means that linkers that need to interlink with a module that refers to stdin directly need to support _ftable.
If a program does not use the stdin, stdout, or stderr macros (or a function implemented as a macro that refers to one of these macros), there are no issues with the FILE array.
C I/O functions commonly implemented as macros—getc, putc, getchar, putchar—must not be inlined.
The fpos_t type is defined as a long.