struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / include / pic14 / stdio.h
blobe786bd6ddc9b4284f2947623acae1b67c151c172
1 /*-------------------------------------------------------------------------
2 stdio.h - ANSI functions forward declarations
4 Copyright (C) 1998, Sandeep Dutta . sandeep.dutta@usa.net
5 Ported to PIC16 port by Vangelis Rokas, 2004 <vrokas AT otenet.gr>
7 Modifications for PIC14 by
8 Copyright (C) 2019 Gonzalo Pérez de Olaguer Córdoba <salo@gpoc.es>
10 This library is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by the
12 Free Software Foundation; either version 2, or (at your option) any
13 later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this library; see the file COPYING. If not, write to the
22 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
23 MA 02110-1301, USA.
25 As a special exception, if you link this library with other files,
26 some of which are compiled with SDCC, to produce an executable,
27 this library does not by itself cause the resulting executable to
28 be covered by the GNU General Public License. This exception does
29 not however invalidate any other reasons why the executable file
30 might be covered by the GNU General Public License.
31 -------------------------------------------------------------------------*/
33 #ifndef __STDIO_H
34 #define __STDIO_H 1
36 #include <stdarg.h>
38 #include <sdcc-lib.h>
40 #ifndef EOF
41 # define EOF (-1)
42 #endif
44 #ifndef NULL
45 #define NULL (void *)0
46 #endif
48 #ifndef __SIZE_T_DEFINED
49 #define __SIZE_T_DEFINED
50 typedef unsigned int size_t;
51 #endif
53 /* Bounds-checking interfaces from annex K of the C11 standard. */
54 #if defined (__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__
56 #ifndef __RSIZE_T_DEFINED
57 #define __RSIZE_T_DEFINED
58 typedef size_t rsize_t;
59 #endif
61 #ifndef __ERRNO_T_DEFINED
62 #define __ERRNO_T_DEFINED
63 typedef int errno_t;
64 #endif
66 #endif
68 /* -------------------------------------------------------------------------
69 * streams description
71 * FILE is a generic pointer, so a stream (FILE*) is a pointer to a generic pointer.
73 * If stream is NULL data will be written by calling to putchar.
75 * If (*stream) points to __data space it is considered a pointer to the
76 * char* buffer being written (sprintf et al.)
78 * If (*stream) points to __code space it is considered a pointer to the
79 * _stream_out_handler that actually handles the write.
80 * -------------------------------------------------------------------------*/
82 typedef void *FILE;
83 typedef int _stream_out_handler (char c, FILE *stream);
85 /* -------------------------------------------------------------------------
86 * Implemented streams. They will be linked to the program only if used.
87 * -------------------------------------------------------------------------*/
89 extern FILE *usart_out;
90 extern FILE *mssp_out;
91 extern FILE *gpsim_out;
93 /* -------------------------------------------------------------------------
94 * The stdout stream is provided by the library and initialized to NULL,
95 * so by default the functions writing to stdout will call putchar.
97 * If another behaviour is desired, the application must assign
98 * to stdout the stream that writes to the desired peripheral.
99 * -------------------------------------------------------------------------*/
101 extern FILE *stdout;
103 /* -------------------------------------------------------------------------
104 * The following functions end up calling fputc with the proper stream.
105 * -------------------------------------------------------------------------*/
107 extern int printf (const char *fmt, ...);
108 extern int sprintf (char *str, const char *fmt, ...);
109 extern int fprintf (FILE *stream, const char *fmt, ...);
111 extern int vprintf (const char *fmt, va_list ap);
112 extern int vsprintf (char *str, const char *fmt, va_list ap);
113 extern int vfprintf (FILE *stream, const char *fmt, va_list ap);
115 extern int fputs (const char *s, FILE *stream);
116 extern int fputc (char c, FILE *stream);
117 #define putc(c,s) fputc(c,s)
119 /* -------------------------------------------------------------------------
120 * The following functions DO NOT use streams.
121 * They end up calling getchar or putchar.
122 * -------------------------------------------------------------------------*/
124 extern void printf_small (const char *fmt, ...);
126 extern int puts(const char *);
128 #if __STDC_VERSION__ < 201112L
129 extern char *gets(char *);
130 #endif
132 /* -------------------------------------------------------------------------
133 * These functions are provided by the library as dummy functions.
134 * They do nothing and return EOF.
135 * The application must provide alternative functions if needed.
136 * -------------------------------------------------------------------------*/
138 extern int getchar(void);
139 extern int putchar(int);
141 #endif /* __STDIO_H */