Suppress noisy pointer signed-ness warnings on x86-64.
[tinycc.git] / win32 / include / stdio.h
blob2d97e668c0b0856d5fce58dd0bbc5d0ffda704b4
1 /*
2 * stdio.h
4 * Definitions of types and prototypes of functions for standard input and
5 * output.
7 * NOTE: The file manipulation functions provided by Microsoft seem to
8 * work with either slash (/) or backslash (\) as the path separator.
10 * This file is part of the Mingw32 package.
12 * Contributors:
13 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
15 * THIS SOFTWARE IS NOT COPYRIGHTED
17 * This source code is offered for use in the public domain. You may
18 * use, modify or distribute it freely.
20 * This code is distributed in the hope that it will be useful but
21 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
22 * DISCLAIMED. This includes but is not limited to warranties of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25 * $Revision: 1.2 $
26 * $Author: bellard $
27 * $Date: 2005/04/17 13:14:29 $
31 #ifndef _STDIO_H_
32 #define _STDIO_H_
34 /* All the headers include this file. */
35 #include <_mingw.h>
37 #define __need_size_t
38 #define __need_NULL
39 #define __need_wchar_t
40 #define __need_wint_t
41 #ifndef RC_INVOKED
42 #include <stddef.h>
43 #endif /* Not RC_INVOKED */
46 /* Flags for the iobuf structure */
47 #define _IOREAD 1
48 #define _IOWRT 2
49 #define _IORW 0x0080 /* opened as "r+w" */
53 * The three standard file pointers provided by the run time library.
54 * NOTE: These will go to the bit-bucket silently in GUI applications!
56 #define STDIN_FILENO 0
57 #define STDOUT_FILENO 1
58 #define STDERR_FILENO 2
60 /* Returned by various functions on end of file condition or error. */
61 #define EOF (-1)
64 * The maximum length of a file name. You should use GetVolumeInformation
65 * instead of this constant. But hey, this works.
67 * NOTE: This is used in the structure _finddata_t (see io.h) so changing it
68 * is probably not a good idea.
70 #define FILENAME_MAX (260)
73 * The maximum number of files that may be open at once. I have set this to
74 * a conservative number. The actual value may be higher.
76 #define FOPEN_MAX (20)
78 /* After creating this many names, tmpnam and tmpfile return NULL */
79 #define TMP_MAX 32767
81 * Tmpnam, tmpfile and, sometimes, _tempnam try to create
82 * temp files in the root directory of the current drive
83 * (not in pwd, as suggested by some older MS doc's).
84 * Redefining these macros does not effect the CRT functions.
86 #define _P_tmpdir "\\"
87 #define _wP_tmpdir L"\\"
90 * The maximum size of name (including NUL) that will be put in the user
91 * supplied buffer caName for tmpnam.
92 * Inferred from the size of the static buffer returned by tmpnam
93 * when passed a NULL argument. May actually be smaller.
95 #define L_tmpnam (16)
97 #define _IOFBF 0x0000
98 #define _IOLBF 0x0040
99 #define _IONBF 0x0004
102 * The buffer size as used by setbuf such that it is equivalent to
103 * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
105 #define BUFSIZ 512
107 /* Constants for nOrigin indicating the position relative to which fseek
108 * sets the file position. Enclosed in ifdefs because io.h could also
109 * define them. (Though not anymore since io.h includes this file now.) */
110 #ifndef SEEK_SET
111 #define SEEK_SET (0)
112 #endif
114 #ifndef SEEK_CUR
115 #define SEEK_CUR (1)
116 #endif
118 #ifndef SEEK_END
119 #define SEEK_END (2)
120 #endif
123 #ifndef RC_INVOKED
126 * I used to include stdarg.h at this point, in order to allow for the
127 * functions later on in the file which use va_list. That conflicts with
128 * using stdio.h and varargs.h in the same file, so I do the typedef myself.
130 #ifndef _VA_LIST
131 #define _VA_LIST
132 #if defined __GNUC__ && __GNUC__ >= 3
133 typedef __builtin_va_list va_list;
134 #else
135 typedef char* va_list;
136 #endif
137 #endif
139 * The structure underlying the FILE type.
141 * I still believe that nobody in their right mind should make use of the
142 * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
143 * <paag@tid.es>.
145 #ifndef _FILE_DEFINED
146 #define _FILE_DEFINED
147 typedef struct _iobuf
149 char* _ptr;
150 int _cnt;
151 char* _base;
152 int _flag;
153 int _file;
154 int _charbuf;
155 int _bufsiz;
156 char* _tmpfname;
157 } FILE;
158 #endif /* Not _FILE_DEFINED */
162 * The standard file handles
164 #ifndef __DECLSPEC_SUPPORTED
166 extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */
168 #define _iob (*__imp__iob) /* An array of FILE */
170 #else /* __DECLSPEC_SUPPORTED */
172 __MINGW_IMPORT FILE _iob[]; /* An array of FILE imported from DLL. */
174 #endif /* __DECLSPEC_SUPPORTED */
176 #define stdin (&_iob[STDIN_FILENO])
177 #define stdout (&_iob[STDOUT_FILENO])
178 #define stderr (&_iob[STDERR_FILENO])
180 #ifdef __cplusplus
181 extern "C" {
182 #endif
185 * File Operations
187 FILE* fopen (const char*, const char*);
188 FILE* freopen (const char*, const char*, FILE*);
189 int fflush (FILE*);
190 int fclose (FILE*);
191 /* MS puts remove & rename (but not wide versions) in io.h also */
192 int remove (const char*);
193 int rename (const char*, const char*);
194 FILE* tmpfile (void);
195 char* tmpnam (char*);
196 char* _tempnam (const char*, const char*);
198 #ifndef NO_OLDNAMES
199 char* tempnam (const char*, const char*);
200 #endif
202 int setvbuf (FILE*, char*, int, size_t);
204 void setbuf (FILE*, char*);
207 * Formatted Output
210 int fprintf (FILE*, const char*, ...);
211 int printf (const char*, ...);
212 int sprintf (char*, const char*, ...);
213 int _snprintf (char*, size_t, const char*, ...);
214 int vfprintf (FILE*, const char*, va_list);
215 int vprintf (const char*, va_list);
216 int vsprintf (char*, const char*, va_list);
217 int _vsnprintf (char*, size_t, const char*, va_list);
219 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
220 int snprintf(char* s, size_t n, const char* format, ...);
221 extern inline int vsnprintf (char* s, size_t n, const char* format,
222 va_list arg)
223 { return _vsnprintf ( s, n, format, arg); }
224 #endif
227 * Formatted Input
230 int fscanf (FILE*, const char*, ...);
231 int scanf (const char*, ...);
232 int sscanf (const char*, const char*, ...);
234 * Character Input and Output Functions
237 int fgetc (FILE*);
238 char* fgets (char*, int, FILE*);
239 int fputc (int, FILE*);
240 int fputs (const char*, FILE*);
241 int getc (FILE*);
242 int getchar (void);
243 char* gets (char*);
244 int putc (int, FILE*);
245 int putchar (int);
246 int puts (const char*);
247 int ungetc (int, FILE*);
250 * Direct Input and Output Functions
253 size_t fread (void*, size_t, size_t, FILE*);
254 size_t fwrite (const void*, size_t, size_t, FILE*);
257 * File Positioning Functions
260 int fseek (FILE*, long, int);
261 long ftell (FILE*);
262 void rewind (FILE*);
264 #ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
266 * Workaround for limitations on win9x where a file contents are
267 * not zero'd out if you seek past the end and then write.
270 int __mingw_fseek (FILE *, long, int);
271 int __mingw_fwrite (const void*, size_t, size_t, FILE*);
272 #define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
273 #define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
274 #endif /* __USE_MINGW_FSEEK */
278 * An opaque data type used for storing file positions... The contents of
279 * this type are unknown, but we (the compiler) need to know the size
280 * because the programmer using fgetpos and fsetpos will be setting aside
281 * storage for fpos_t structres. Actually I tested using a byte array and
282 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
283 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
284 * MSVCRT however, and for now `long long' will do.
286 #ifdef __MSVCRT__
287 typedef long long fpos_t;
288 #else
289 typedef long fpos_t;
290 #endif
292 int fgetpos (FILE*, fpos_t*);
293 int fsetpos (FILE*, const fpos_t*);
296 * Error Functions
299 void clearerr (FILE*);
300 int feof (FILE*);
301 int ferror (FILE*);
302 void perror (const char*);
305 #ifndef __STRICT_ANSI__
307 * Pipes
309 FILE* _popen (const char*, const char*);
310 int _pclose (FILE*);
312 #ifndef NO_OLDNAMES
313 FILE* popen (const char*, const char*);
314 int pclose (FILE*);
315 #endif
318 * Other Non ANSI functions
320 int _flushall (void);
321 int _fgetchar (void);
322 int _fputchar (int);
323 FILE* _fdopen (int, const char*);
324 int _fileno (FILE*);
326 #ifndef _NO_OLDNAMES
327 int fgetchar (void);
328 int fputchar (int);
329 FILE* fdopen (int, const char*);
330 int fileno (FILE*);
331 #endif /* Not _NO_OLDNAMES */
333 #endif /* Not __STRICT_ANSI__ */
335 /* Wide versions */
337 #ifndef _WSTDIO_DEFINED
338 /* also in wchar.h - keep in sync */
339 int fwprintf (FILE*, const wchar_t*, ...);
340 int wprintf (const wchar_t*, ...);
341 int swprintf (wchar_t*, const wchar_t*, ...);
342 int _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
343 int vfwprintf (FILE*, const wchar_t*, va_list);
344 int vwprintf (const wchar_t*, va_list);
345 int vswprintf (wchar_t*, const wchar_t*, va_list);
346 int _vsnwprintf (wchar_t*, size_t, const wchar_t*, va_list);
347 int fwscanf (FILE*, const wchar_t*, ...);
348 int wscanf (const wchar_t*, ...);
349 int swscanf (const wchar_t*, const wchar_t*, ...);
350 wint_t fgetwc (FILE*);
351 wint_t fputwc (wchar_t, FILE*);
352 wint_t ungetwc (wchar_t, FILE*);
353 #ifdef __MSVCRT__
354 wchar_t* fgetws (wchar_t*, int, FILE*);
355 int fputws (const wchar_t*, FILE*);
356 wint_t getwc (FILE*);
357 wint_t getwchar (void);
358 wchar_t* _getws (wchar_t*);
359 wint_t putwc (wint_t, FILE*);
360 int _putws (const wchar_t*);
361 wint_t putwchar (wint_t);
362 FILE* _wfopen (const wchar_t*, const wchar_t*);
363 FILE* _wfreopen (const wchar_t*, const wchar_t*, FILE*);
364 FILE* _wfsopen (const wchar_t*, const wchar_t*, int);
365 wchar_t* _wtmpnam (wchar_t*);
366 wchar_t* _wtempnam (const wchar_t*, const wchar_t*);
367 int _wrename (const wchar_t*, const wchar_t*);
368 int _wremove (const wchar_t*);
369 void _wperror (const wchar_t*);
370 FILE* _wpopen (const wchar_t*, const wchar_t*);
371 #endif /* __MSVCRT__ */
373 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
374 int snwprintf(wchar_t* s, size_t n, const wchar_t* format, ...);
375 extern inline int vsnwprintf (wchar_t* s, size_t n, const wchar_t* format,
376 va_list arg)
377 { return _vsnwprintf ( s, n, format, arg); }
378 #endif
380 #define _WSTDIO_DEFINED
381 #endif /* _WSTDIO_DEFINED */
383 #ifndef __STRICT_ANSI__
384 #ifdef __MSVCRT__
385 #ifndef NO_OLDNAMES
386 FILE* wpopen (const wchar_t*, const wchar_t*);
387 #endif /* not NO_OLDNAMES */
388 #endif /* MSVCRT runtime */
391 * Other Non ANSI wide functions
393 wint_t _fgetwchar (void);
394 wint_t _fputwchar (wint_t);
395 int _getw (FILE*);
396 int _putw (int, FILE*);
398 #ifndef _NO_OLDNAMES
399 wint_t fgetwchar (void);
400 wint_t fputwchar (wint_t);
401 int getw (FILE*);
402 int putw (int, FILE*);
403 #endif /* Not _NO_OLDNAMES */
405 #endif /* __STRICT_ANSI */
407 #ifdef __cplusplus
409 #endif
411 #endif /* Not RC_INVOKED */
413 #endif /* _STDIO_H_ */