哪位大神能详细分析下stdio.h

飘逸的虚空 2012-05-15 11:51:38
/***
*stdio.h - definitions/declarations for standard I/O routines
*
* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* This file defines the structures, values, macros, and functions
* used by the level 2 I/O ("standard I/O") routines.
* [ANSI/System V]
*
* [Public]
*
****/

#if _MSC_VER > 1000
#pragma once
#endif

#ifndef _INC_STDIO
#define _INC_STDIO

#if !defined(_WIN32) && !defined(_MAC)
#error ERROR: Only Mac or Win32 targets supported!
#endif


#ifdef _MSC_VER
/*
* Currently, all MS C compilers for Win32 platforms default to 8 byte
* alignment.
*/
#pragma pack(push,8)
#endif /* _MSC_VER */

#ifdef __cplusplus
extern "C" {
#endif



/* Define _CRTIMP */

#ifndef _CRTIMP
#ifdef _DLL
#define _CRTIMP __declspec(dllimport)
#else /* ndef _DLL */
#define _CRTIMP
#endif /* _DLL */
#endif /* _CRTIMP */


/* Define __cdecl for non-Microsoft compilers */

#if ( !defined(_MSC_VER) && !defined(__cdecl) )
#define __cdecl
#endif

/* Define _CRTAPI1 (for compatibility with the NT SDK) */

#ifndef _CRTAPI1
#if _MSC_VER >= 800 && _M_IX86 >= 300
#define _CRTAPI1 __cdecl
#else
#define _CRTAPI1
#endif
#endif


#ifndef _SIZE_T_DEFINED
typedef unsigned int size_t;
#define _SIZE_T_DEFINED
#endif


#ifndef _MAC
#ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif


#ifndef _WCTYPE_T_DEFINED
typedef wchar_t wint_t;
typedef wchar_t wctype_t;
#define _WCTYPE_T_DEFINED
#endif
#endif /* ndef _MAC */


#ifndef _VA_LIST_DEFINED
#ifdef _M_ALPHA
typedef struct {
char *a0; /* pointer to first homed integer argument */
int offset; /* byte offset of next parameter */
} va_list;
#else
typedef char * va_list;
#endif
#define _VA_LIST_DEFINED
#endif


/* Buffered I/O macros */

#if defined(_M_MPPC)
#define BUFSIZ 4096
#else /* defined (_M_MPPC) */
#define BUFSIZ 512
#endif /* defined (_M_MPPC) */


/*
* Default number of supported streams. _NFILE is confusing and obsolete, but
* supported anyway for backwards compatibility.
*/
#define _NFILE _NSTREAM_

#ifdef _WIN32

#define _NSTREAM_ 512

/*
* Number of entries in _iob[] (declared below). Note that _NSTREAM_ must be
* greater than or equal to _IOB_ENTRIES.
*/
#define _IOB_ENTRIES 20

#else /* ndef _WIN32 */

#ifdef _DLL
#define _NSTREAM_ 128
#else
#ifdef _MT
#define _NSTREAM_ 40
#else
#define _NSTREAM_ 20
#endif
#endif /* _DLL */

#endif /* ndef _MAC */

#define EOF (-1)


#ifndef _FILE_DEFINED
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;
#define _FILE_DEFINED
#endif


#ifndef _MAC

/* Directory where temporary files may be created. */

#ifdef _POSIX_
#define _P_tmpdir "/"
#define _wP_tmpdir L"/"
#else
#define _P_tmpdir "\\"
#define _wP_tmpdir L"\\"
#endif

/* L_tmpnam = size of P_tmpdir
* + 1 (in case P_tmpdir does not end in "/")
* + 12 (for the filename string)
* + 1 (for the null terminator)
*/
#define L_tmpnam sizeof(_P_tmpdir)+12

#else /* def _MAC */

#define L_tmpnam 255

#endif /* _MAC */


#ifdef _POSIX_
#define L_ctermid 9
#define L_cuserid 32
#endif


/* Seek method constants */

#define SEEK_CUR 1
#define SEEK_END 2
#define SEEK_SET 0


#define FILENAME_MAX 260
#define FOPEN_MAX 20
#define _SYS_OPEN 20
#define TMP_MAX 32767


/* Define NULL pointer value */

#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif



我们老师叫我们自己写头文件、 参照自带的include的文件格式,哪位高手能分析下上面代码的具体含义,有多少是多少。或者写头文件的格式也行呀、感激不尽、
...全文
248 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zk2802996 2012-05-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

我只是弄了一小部分,我们老师目的是让我们规范写自己常用的头文件,就是要一些宏定义什么的,让代码规范啊引用 3 楼 的回复:
都是一些定义,
哪有什么函数。
[/Quote]

#if _MSC_VER > 1000 //MFC版本 大于4.21
#pragma once //只编译一次
#endif //条件编译结束

#ifndef _INC_STDIO //如果没有定义_INC_STDIO,那么定义_INC_STDIO
#define _INC_STDIO

#if !defined(_WIN32) && !defined(_MAC) //这里是判断程序所运行的是什么操作系统上
#error ERROR: Only Mac or Win32 targets supported!
#endif

像这样的头文件写的很严谨的,而且是可以跨平台的
头文件放些函数声明,宏定义,头文件保护符....
爱哭的你 2012-05-19
  • 打赏
  • 举报
回复
如果想写自己的头文件的话,,可以去看unix内核方面的书 ,,里面像这样的文件讲的很清楚
nanchangfantasy 2012-05-16
  • 打赏
  • 举报
回复
这问题提得太有水分了
wq19901103wq 2012-05-16
  • 打赏
  • 举报
回复
stdio是标准输入输出吧,感觉你这里不全,都是些宏定义和结构体,没有函数体输入输出
看了没什么用,你们老师纯粹吃饱了没事干,要是不抄它我肯定写不出来
飘逸的虚空 2012-05-16
  • 打赏
  • 举报
回复
我只是弄了一小部分,我们老师目的是让我们规范写自己常用的头文件,就是要一些宏定义什么的,让代码规范啊[Quote=引用 3 楼 的回复:]
都是一些定义,
哪有什么函数。
[/Quote]
弘毅致远 2012-05-16
  • 打赏
  • 举报
回复
都是一些定义,
哪有什么函数。

33,008

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧