📄 stdio.h
字号:
/* * stdio.h * This file has no copyright assigned and is placed in the Public Domain. * This file is a part of the mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER within the package. * * Definitions of types and prototypes of functions for standard input and * output. * * NOTE: The file manipulation functions provided by Microsoft seem to * work with either slash (/) or backslash (\) as the directory separator. * */#ifndef _STDIO_H_#define _STDIO_H_/* All the headers include this file. */#include <_mingw.h>#ifndef RC_INVOKED#define __need_size_t#define __need_NULL#define __need_wchar_t#define __need_wint_t#include <stddef.h>#define __need___va_list#include <stdarg.h>#endif /* Not RC_INVOKED *//* Flags for the iobuf structure */#define _IOREAD 1 /* currently reading */#define _IOWRT 2 /* currently writing */#define _IORW 0x0080 /* opened as "r+w" *//* * The three standard file pointers provided by the run time library. * NOTE: These will go to the bit-bucket silently in GUI applications! */#define STDIN_FILENO 0#define STDOUT_FILENO 1#define STDERR_FILENO 2/* Returned by various functions on end of file condition or error. */#define EOF (-1)/* * The maximum length of a file name. You should use GetVolumeInformation * instead of this constant. But hey, this works. * Also defined in io.h. */#ifndef FILENAME_MAX#define FILENAME_MAX (260)#endif/* * The maximum number of files that may be open at once. I have set this to * a conservative number. The actual value may be higher. */#define FOPEN_MAX (20)/* After creating this many names, tmpnam and tmpfile return NULL */#define TMP_MAX 32767/* * Tmpnam, tmpfile and, sometimes, _tempnam try to create * temp files in the root directory of the current drive * (not in pwd, as suggested by some older MS doc's). * Redefining these macros does not effect the CRT functions. */#define _P_tmpdir "\\"#ifndef __STRICT_ANSI__#define P_tmpdir _P_tmpdir#endif#define _wP_tmpdir L"\\"/* * The maximum size of name (including NUL) that will be put in the user * supplied buffer caName for tmpnam. * Inferred from the size of the static buffer returned by tmpnam * when passed a NULL argument. May actually be smaller. */#define L_tmpnam (16)#define _IOFBF 0x0000 /* full buffered */#define _IOLBF 0x0040 /* line buffered */#define _IONBF 0x0004 /* not buffered */#define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */#define _IOEOF 0x0010 /* EOF reached on read */#define _IOERR 0x0020 /* I/O error from system */#define _IOSTRG 0x0040 /* Strange or no file descriptor */#ifdef _POSIX_SOURCE# define _IOAPPEND 0x0200#endif/* * The buffer size as used by setbuf such that it is equivalent to * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ). */#define BUFSIZ 512/* Constants for nOrigin indicating the position relative to which fseek * sets the file position. Defined unconditionally since ISO and POSIX * say they are defined here. */#define SEEK_SET 0#define SEEK_CUR 1#define SEEK_END 2#ifndef RC_INVOKED#ifndef __VALIST#ifdef __GNUC__#define __VALIST __gnuc_va_list#else#define __VALIST char*#endif#endif /* defined __VALIST *//* * The structure underlying the FILE type. * * Some believe that nobody in their right mind should make use of the * internals of this structure. Provided by Pedro A. Aranda Gutiirrez * <paag@tid.es>. */#ifndef _FILE_DEFINED#define _FILE_DEFINEDtypedef struct _iobuf{ char* _ptr; int _cnt; char* _base; int _flag; int _file; int _charbuf; int _bufsiz; char* _tmpfname;} FILE;#endif /* Not _FILE_DEFINED *//* * The standard file handles */#ifndef __DECLSPEC_SUPPORTEDextern FILE (*_imp___iob)[]; /* A pointer to an array of FILE */#define _iob (*_imp___iob) /* An array of FILE */#else /* __DECLSPEC_SUPPORTED */__MINGW_IMPORT FILE _iob[]; /* An array of FILE imported from DLL. */#endif /* __DECLSPEC_SUPPORTED */#define stdin (&_iob[STDIN_FILENO])#define stdout (&_iob[STDOUT_FILENO])#define stderr (&_iob[STDERR_FILENO])#ifdef __cplusplusextern "C" {#endif/* * File Operations */_CRTIMP FILE* __cdecl __MINGW_NOTHROW fopen (const char*, const char*);_CRTIMP FILE* __cdecl __MINGW_NOTHROW freopen (const char*, const char*, FILE*);_CRTIMP int __cdecl __MINGW_NOTHROW fflush (FILE*);_CRTIMP int __cdecl __MINGW_NOTHROW fclose (FILE*);/* MS puts remove & rename (but not wide versions) in io.h also */_CRTIMP int __cdecl __MINGW_NOTHROW remove (const char*);_CRTIMP int __cdecl __MINGW_NOTHROW rename (const char*, const char*);_CRTIMP FILE* __cdecl __MINGW_NOTHROW tmpfile (void);_CRTIMP char* __cdecl __MINGW_NOTHROW tmpnam (char*);#ifndef __STRICT_ANSI___CRTIMP char* __cdecl __MINGW_NOTHROW _tempnam (const char*, const char*);_CRTIMP int __cdecl __MINGW_NOTHROW _rmtmp(void);_CRTIMP int __cdecl __MINGW_NOTHROW _unlink (const char*);#ifndef NO_OLDNAMES_CRTIMP char* __cdecl __MINGW_NOTHROW tempnam (const char*, const char*);_CRTIMP int __cdecl __MINGW_NOTHROW rmtmp(void);_CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*);#endif#endif /* __STRICT_ANSI__ */_CRTIMP int __cdecl __MINGW_NOTHROW setvbuf (FILE*, char*, int, size_t);_CRTIMP void __cdecl __MINGW_NOTHROW setbuf (FILE*, char*);/* * Formatted Output * * MSVCRT implementations are not ANSI C99 conformant... * we offer these conforming alternatives from libmingwex.a */#undef __mingw_stdio_redirect__#define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __mingw_##Fextern int __mingw_stdio_redirect__(fprintf)(FILE*, const char*, ...);extern int __mingw_stdio_redirect__(printf)(const char*, ...);extern int __mingw_stdio_redirect__(sprintf)(char*, const char*, ...);extern int __mingw_stdio_redirect__(snprintf)(char*, size_t, const char*, ...);extern int __mingw_stdio_redirect__(vfprintf)(FILE*, const char*, __VALIST);extern int __mingw_stdio_redirect__(vprintf)(const char*, __VALIST);extern int __mingw_stdio_redirect__(vsprintf)(char*, const char*, __VALIST);extern int __mingw_stdio_redirect__(vsnprintf)(char*, size_t, const char*, __VALIST);#if __USE_MINGW_ANSI_STDIO/* * User has expressed a preference for C99 conformance... */# undef __mingw_stdio_redirect__# ifdef __cplusplus/* * For C++ we use inline implementations, to avoid interference * with namespace qualification, which may result from using #defines. */# define __mingw_stdio_redirect__ static inline __cdecl __MINGW_NOTHROW# elif defined __GNUC__/* * FIXME: Is there any GCC version prerequisite here? * * We also prefer inline implementations for C, when we can be confident * that the GNU specific __inline__ mechanism is supported. */# define __mingw_stdio_redirect__ static __inline__ __cdecl __MINGW_NOTHROW# else/* * Can't use inlines; fall back on module local static stubs. */# define __mingw_stdio_redirect__ static __cdecl __MINGW_NOTHROW# endif__mingw_stdio_redirect__int fprintf (FILE *__stream, const char *__format, ...){ register int __retval; __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format ); __retval = __mingw_vfprintf( __stream, __format, __local_argv ); __builtin_va_end( __local_argv ); return __retval;}__mingw_stdio_redirect__int printf (const char *__format, ...){ register int __retval; __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format ); __retval = __mingw_vprintf( __format, __local_argv ); __builtin_va_end( __local_argv ); return __retval;}__mingw_stdio_redirect__int sprintf (char *__stream, const char *__format, ...){ register int __retval; __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format ); __retval = __mingw_vsprintf( __stream, __format, __local_argv ); __builtin_va_end( __local_argv ); return __retval;}__mingw_stdio_redirect__int vfprintf (FILE *__stream, const char *__format, __VALIST __local_argv){ return __mingw_vfprintf( __stream, __format, __local_argv );}__mingw_stdio_redirect__int vprintf (const char *__format, __VALIST __local_argv){ return __mingw_vprintf( __format, __local_argv );}__mingw_stdio_redirect__int vsprintf (char *__stream, const char *__format, __VALIST __local_argv){ return __mingw_vsprintf( __stream, __format, __local_argv );}#else/* * Default configuration: simply direct all calls to MSVCRT... */_CRTIMP int __cdecl __MINGW_NOTHROW fprintf (FILE*, const char*, ...);_CRTIMP int __cdecl __MINGW_NOTHROW printf (const char*, ...);_CRTIMP int __cdecl __MINGW_NOTHROW sprintf (char*, const char*, ...);_CRTIMP int __cdecl __MINGW_NOTHROW vfprintf (FILE*, const char*, __VALIST);_CRTIMP int __cdecl __MINGW_NOTHROW vprintf (const char*, __VALIST);_CRTIMP int __cdecl __MINGW_NOTHROW vsprintf (char*, const char*, __VALIST);#endif/* * Regardless of user preference, always offer these alternative * entry points, for direct access to the MSVCRT implementations. */#undef __mingw_stdio_redirect__#define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __msvcrt_##F_CRTIMP int __mingw_stdio_redirect__(fprintf)(FILE*, const char*, ...);_CRTIMP int __mingw_stdio_redirect__(printf)(const char*, ...);_CRTIMP int __mingw_stdio_redirect__(sprintf)(char*, const char*, ...);_CRTIMP int __mingw_stdio_redirect__(vfprintf)(FILE*, const char*, __VALIST);_CRTIMP int __mingw_stdio_redirect__(vprintf)(const char*, __VALIST);_CRTIMP int __mingw_stdio_redirect__(vsprintf)(char*, const char*, __VALIST);#undef __mingw_stdio_redirect__/* The following pair ALWAYS refer to the MSVCRT implementations... */_CRTIMP int __cdecl __MINGW_NOTHROW _snprintf (char*, size_t, const char*, ...);_CRTIMP int __cdecl __MINGW_NOTHROW _vsnprintf (char*, size_t, const char*, __VALIST);#ifndef __NO_ISOCEXT /* externs in libmingwex.a *//* * Microsoft does not provide implementations for the following,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -