本文主要是介绍libc.a中FILE结构的分析,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
stdio.h中有FILE结构的定义
typedef char __stdiobuf_t; /* stdio buffer type */
typedef STDIO_USIZE_T __stdiosize_t; /* unsigned size_t */
typedef struct __iobuf {
__stdiobuf_t __rptr; / pointer into read buffer */
__stdiobuf_t __rend; / point at end of read buffer */
__stdiobuf_t __wptr; / pointer into write buffer */
__stdiobuf_t __wend; / point at end of write buffer */
__stdiobuf_t __base; / base of buffer */
__stdiosize_t __bufsiz; /* size of buffer */
short __flag; /* flags */
char __file; /* channel number */
__stdiobuf_t __buf; /* small buffer */
int (__filbuf) _STDIO_P_((struct __iobuf )); /* fill input buffer */
int (__flsbuf) _STDIO_P_((int, struct __iobuf )); /* flush output buffer */
int (__flush) _STDIO_P_((struct __iobuf )); /* flush buffer */
struct __iobuf __next; / next in chain */
} FILE;
stdiolib.h中有宏定义
define SETFILBUF(f,p) ( (f)->__filbuf = (p) )
define TESTFLAG(f,x) (((f)->__flag & (x)) != 0)
fseek.c中有对filbuf函数指针的赋值
SETFILBUF(fp, __brdupdate);
这篇关于libc.a中FILE结构的分析的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!