您的位置:首页 > 编程语言 > C语言/C++

C++ #,##,stdin,stdout,stderr

2016-01-07 16:27 489 查看
<pre name="code" class="cpp">// 标准输入,标准输出,标准错误输出
/* Declare _iob[] array */

#ifndef _STDIO_DEFINED
_CRTIMP FILE * __cdecl __iob_func(void);
#endif  /* _STDIO_DEFINED */


#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 _STDSTREAM_DEFINED#define stdin (&__iob_func()[0])#define stdout (&__iob_func()[1])#define stderr (&__iob_func()[2])#define _STDSTREAM_DEFINED#endif

/*
* FILE descriptors; preset for stdin/out/err (note that the __tmpnum field
* is not initialized)
*/
FILE _iob[_IOB_ENTRIES] = {
/* _ptr, _cnt, _base,  _flag, _file, _charbuf, _bufsiz */

/* stdin (_iob[0]) */

{ _bufin, 0, _bufin, _IOREAD | _IOYOURBUF, 0, 0, _INTERNAL_BUFSIZ },

/* stdout (_iob[1]) */

{ NULL, 0, NULL, _IOWRT, 1, 0, 0 },

/* stderr (_iob[3]) */

{ NULL, 0, NULL, _IOWRT, 2, 0, 0 },

};

/* These functions are for enabling STATIC_CPPLIB functionality */
_CRTIMP FILE * __cdecl __iob_func(void)
{
return _iob;
}


#:将其后面的宏参数进行字符串化操作(Stringfication),简单说就是在对它所引用的宏变量通过替换后在其左右各加上一个双引号

##:连接符(concatenator),用来将两个Token连接为一个Token。注意这里连接的对象是Token就行,而不一定是宏的变量
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: