最好,最包含哲理的Hello,World
c吧
全部回复
仅看楼主
level 1
Mankiny 楼主
/*
* stdio.h
*
* Definitions of types and prototypes of functions for operations on
* standard input and standard output streams.
*
* $Id: stdio.h,v 0fe8afb3a429 2019/10/26 09:33:12 keith $
*
* Written by Colin Peters
* Copyright (C) 1997-2005, 2007-2010, 2014-2019, MinGW.org Project.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice, this permission notice, and the following
* disclaimer shall be included in all copies or substantial portions of
* the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OF OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* NOTE: The file manipulation functions provided by Microsoft seem to
* work with either slash (/) or backslash (\) as the directory separator;
* (this is consistent with Microsoft's own documentation, on MSDN).
*
*/
#ifndef _STDIO_H
/* When including , some of the definitions and declarations
* which are nominally provided in must be duplicated. Rather
* than require duplicated maintenance effort, we provide for partial
* inclusion of by ; only when not included in
* this partial fashion...
*/
#ifndef __WCHAR_H_SOURCED__
/* ...which is exclusive to , do we assert the multiple
* inclusion guard for itself.
*/
#define _STDIO_H
#endif
/* All the headers include this file.
*/
#include <_mingw.h>
#ifndef RC_INVOKED
/* POSIX stipulates that the following set of types, (as identified by
* __need_TYPENAME macros), shall be defined consistently with ;
* by defining the appropriate __need_TYPENAME macros, we may selectively
* obtain the required definitions by inclusion of , WITHOUT
* automatic exposure of any of its additional content.
*/
#define __need_NULL
#define __need_size_t
#define __need_wchar_t
#define __need_wint_t
#include
#if _POSIX_C_SOURCE >= 200809L
/* Similarly, for types defined in , (which are explicitly
* dependent on the POSIX.1-2008 feature test)...
*/
# define __need_off_t
# define __need_ssize_t
#endif
/* Although non-standard themselves, we also need either one or other
* of the following pair of data types, from , because our
* standard fpos_t is opaquely defined in terms of...
*/
#ifdef __MSVCRT__
/* ...an explicitly 64-bit file offset type, for MSVCRT.DLL users...
*/
# define __need___off64_t
#else
/* ...or a 32-bit equivalent, for pre-MSVCRT.DLL users.
*/
# define __need___off32_t
#endif
/* Note the use of the #include "..." form here, to ensure that we get
* the correct header file, relative to the location of this
*/
#include "sys/types.h"
#ifndef __VALIST
/* Also similarly, for the va_list type, defined in "stdarg.h"
*/
# if defined __GNUC__ && __GNUC__ >= 3
# define __need___va_list
# include "stdarg.h"
# define __VALIST __builtin_va_list
# else
# define __VALIST char *
# endif
#endif
#endif/* ! RC_INVOKED */
#ifdef _STDIO_H
/* Flags for the iobuf structure
*/
#define _IOREAD 1/* currently reading */
#define _IOWRT2/* 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_FILENO0
#define STDOUT_FILENO1
#define STDERR_FILENO2
/* Returned by various functions on end of file condition or error.
*/
#define EOF (-1)
#endif/* _STDIO_H */
/* The maximum length of a file name. It may be better to use the Windows'
* GetVolumeInformation() function in preference to this constant, but hey,
* this works! Note that also defines it, but we don't guard it, so
* that the compiler has a chance to catch inconsistencies.
*
* FIXME: Right now, we define this unconditionally for both full
* inclusion, and for partial inclusion on behalf of , (which needs
* it for some non-ANSI structure declarations). The conditions under which
* needs this require review, because defining it as a consequence
* of including alone may violate strict ANSI conformity.
*/
#define FILENAME_MAX (260)
#ifdef _STDIO_H
/* 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 _IOFBF0x0000/* full buffered */
#define _IOLBF0x0040/* line buffered */
#define _IONBF0x0004/* not buffered */
#define _IOMYBUF0x0008/* stdio malloc()'d buffer */
#define _IOEOF0x0010/* EOF reached on read */
#define _IOERR0x0020/* I/O error from system */
#define _IOSTRG 0x0040/* Strange or no file descriptor */
#ifdef _POSIX_SOURCE
# define _IOAPPEND0x0200
#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
#endif/* _STDIO_H */
#ifndef RC_INVOKED
#if ! (defined _STDIO_H && defined _WCHAR_H)
/* The structure underlying the FILE type; this should be defined when
* including either or . If both header include guards
* are now in place, then we must currently be including in its
* own right, having already processed this block during a prior partial
* inclusion by ; there is no need to process it a second time.
*
* Some believe that nobody in their right mind should make use of the
* internals of this structure. Provided by Pedro A. Aranda Gutiirrez
* .
*/
typedef struct _iobuf
{
char*_ptr;
int _cnt;
char*_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char*_tmpfname;
} FILE;
#endif /* ! (_STDIO_H && _WCHAR_H) */
#ifdef _STDIO_H
/* Content to be exposed only when including in its own right;
* these will not be exposed when __WCHAR_H_SOURCE__ is defined, as will
* be the case when is included indirectly, by
*
*
* The standard file handles
*/
#ifndef __DEC
LSP
EC_SUPPORTED
extern 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])
/* Need to close the current _STDIO_H specific block here...
*/
#endif
/* ...because, we need this regardless of the inclusion mode...
*/
_BEGIN_C_DECLS
#ifdef _STDIO_H
/* ...then revert to _STDIO_H specific mode, to declare...
*
*
* File Operations
*/
_CRTIMP __cdecl __MINGW_NOTHROW FILE * fopen (const char *, const char *);
_CRTIMP __cdecl __MINGW_NOTHROW FILE * freopen (const char *, const char *, FILE *);
_CRTIMP __cdecl __MINGW_NOTHROW int fflush (FILE *);
_CRTIMP __cdecl __MINGW_NOTHROW int fclose (FILE *);
/* Note: Microsoft also declares remove & rename (but not their wide char
* variants) in ; since duplicate prototypes are acceptable, provided
* they are consistent, we simply declare them here anyway, while allowing
* the compiler to check consistency as appropriate.
*/
_CRTIMP __cdecl __MINGW_NOTHROW int remove (const char *);
_CRTIMP __cdecl __MINGW_NOTHROW int rename (const char *, const char *);
_CRTIMP __cdecl __MINGW_NOTHROW FILE * tmpfile (void);
_CRTIMP __cdecl __MINGW_NOTHROW char * tmpnam (char *);
#ifndef __STRICT_ANSI__
_CRTIMP __cdecl __MINGW_NOTHROW char *_tempnam (const char *, const char *);
_CRTIMP __cdecl __MINGW_NOTHROW int _rmtmp (void);
_CRTIMP __cdecl __MINGW_NOTHROW int _unlink (const char *);
#if __MSVCRT_VERSION__>=__MSVCR80_DLL
/* The following pair of non-ANSI functions require a non-free version of
* the Microsoft runtime; neither is provided by any MSVCRT.DLL variant.
*/
_CRTIMP __cdecl __MINGW_NOTHROW void _lock_file(FILE *);
_CRTIMP __cdecl __MINGW_NOTHROW void _unlock_file(FILE *);
#endif
#ifndef NO_OLDNAMES
_CRTIMP __cdecl __MINGW_NOTHROW char * tempnam (const char *, const char *);
_CRTIMP __cdecl __MINGW_NOTHROW int rmtmp (void);
_CRTIMP __cdecl __MINGW_NOTHROW int unlink (const char *);
#endif
#endif /* __STRICT_ANSI__ */
_CRTIMP __cdecl __MINGW_NOTHROW int setvbuf (FILE *, char *, int, size_t);
_CRTIMP __cdecl __MINGW_NOTHROW void setbuf (FILE *, char *);
/* Formatted Output
*
* MSVCRT implementations are not ANSI C99 conformant...
* we offer conforming alternatives from libmingwex.a
*/
#undef __mingw_stdio_redirect__
#define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __Wformat(F)
#define __Wformat_mingw_printf(F,A) __attribute__((__format__(__mingw_printf__,F,A)))
#if __GNUC__ >= 6
/* From GCC-6 onwards, we will provide customized -Wformat
* handling, via our own mingw_printf format category...
*/
#define __Wformat(F)__Wformat_#
#F __mingw_#
#F
#else/* __GNUC__ < 6 */
/* ...whereas, for earlier GCC, we preserve the status quo,
* offering no -Wformat checking for those functions which
* replace the MSVCRT.DLL versions...
*/

#define __Wformat(F)__mingw_#
#F
/* ...while degrading to gnu_printf checking for snprintf()
* and vsnprintf(), (which are ALWAYS MinGW.org variants).
*/
#define __mingw_printf____gnu_printf__
#endif
/* The following convenience macros specify the appropriate
* -Wformat checking for MSVCRT.DLL replacement functions...
*/
#define __Wformat_printf__Wformat_mingw_printf(1,2)
#define __Wformat_fprintf__Wformat_mingw_printf(2,3)
#define __Wformat_sprintf__Wformat_mingw_printf(2,3)
#define __Wformat_vprintf__Wformat_mingw_printf(1,0)
#define __Wformat_vfprintf__Wformat_mingw_printf(2,0)
#define __Wformat_vsprintf__Wformat_mingw_printf(2,0)
/* ...while this pair are specific to the two MinGW.org
* only functions.
*/
#define __Wformat_snprintf__Wformat_mingw_printf(3,4)
#define __Wformat_vsnprintf__Wformat_mingw_printf(3,0)
extern 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);
/* When using these C99 conforming alternatives, we may wish to support
* some of Microsoft's quirky formatting options, even when they violate
* strict C99 conformance.
*/
#define _MSVC_PRINTF_QUIRKS0x0100U
#define _QUERY_MSVC_PRINTF_QUIRKS~0U, 0U
#define _DISABLE_MSVC_PRINTF_QUIRKS~_MSVC_PRINTF_QUIRKS, 0U
2022年11月23日 14点11分 1
1