linux FILE 类型.
Linux 类型 File
2023-09-27 14:28:06 时间
stdio.h 头文件中,有以下内容(用内部行号解释):
1 /* The opaque type of streams. This is the definition used elsewhere. */ 2 46 typedef struct _IO_FILE FILE; 3 ... 4 #include <libio.h> 5 ... 6 /* Standard streams. */ 7 142 extern struct _IO_FILE *stdin; /* Standard input stream. */ 8 143 extern struct _IO_FILE *stdout; /* Standard output stream. */ 9 144 extern struct _IO_FILE *stderr; /* Standard error output stream. */145 #ifdef __STDC__ 10 146 /* C89/C99 say they're macros. Make them happy. */ 11 147 #define stdin stdin 12 148 #define stdout stdout 13 149 #define stderr stderr 14 150 #endif
由上,知道 FILE 是 struct _IO_FILE 类型的别名,或者说 FILE 类型就是 struct _IO_FILE 类型,由 第143行中的 _IO_FILE,往上追溯至 include 预处理指令,我们可以在 libio.h 头文件中看到 _IO_FILE 结构体的定义:
1 struct _IO_FILE { 2 269 int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ 3 270 #define _IO_file_flags _flags 4 271 5 272 /* The following pointers correspond to the C++ streambuf protocol. */ 6 273 /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ 7 274 char* _IO_read_ptr; /* Current read pointer */ 8 275 char* _IO_read_end; /* End of get area. */ 9 276 char* _IO_read_base; /* Start of putback+get area. */ 10 277 char* _IO_write_base; /* Start of put area. */ 11 278 char* _IO_write_ptr; /* Current put pointer. */ 12 279 char* _IO_write_end; /* End of put area. */ 13 280 char* _IO_buf_base; /* Start of reserve area. */ 14 281 char* _IO_buf_end; /* End of reserve area. */ 15 282 /* The following fields are used to support backing up and undo. */ 16 283 char *_IO_save_base; /* Pointer to start of non-current get area. */ 17 284 char *_IO_backup_base; /* Pointer to first valid character of backup area */ 18 285 char *_IO_save_end; /* Pointer to end of non-current get area. */ 19 286 20 287 struct _IO_marker *_markers; 21 288 22 289 struct _IO_FILE *_chain; 23 24 291 int _fileno; 25 292 #if 0 26 293 int _blksize; 27 294 #else 28 295 int _flags2; 29 296 #endif 30 297 _IO_off_t _old_offset; /* This used to be _offset but it's too small. */ 31 298 32 299 #define __HAVE_COLUMN /* temporary */ 33 300 /* 1+column number of pbase(); 0 is unknown. */ 34 301 unsigned short _cur_column; 35 302 signed char _vtable_offset; 36 303 char _shortbuf[1]; 37 304 38 305 /* char* _save_gptr; char* _save_egptr; */ 39 306 40 307 _IO_lock_t *_lock; 41 308 #ifdef _IO_USE_OLD_IO_FILE 42 309 };
稍微注意的是(外侧行号解释), stdio.h 头文件中的第 4行优先于第 2 行执行,虽然第2行在第4行的前面.
相关文章
- 【ARM-Linux开发】【CUDA开发】【深度学习与神经网络】Jetson Tx2安装相关之一
- linux下用户空间操作物理内存地址
- Linux安装JDK完整步骤
- 第二章:Linux 基础篇章
- Linux的终端类型
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件 *****
- linux多进程之间的文件锁
- linux 入门命令总结
- linux 判空处理
- Linux 自定义总线类型
- linux 单网卡绑定两个ip
- linux统计文件中字符串次数及文件夹下特定类型文件个数
- 嵌入式linux/鸿蒙开发板(IMX6ULL)开发(二十七)具体单板的LED驱动程序
- Linux SSL 双向认证 浅解
- Linux下2号进程的kthreadd--Linux进程的管理与调度(七)
- Linux下6种优秀的邮件传输代理
- 查看Linux系统架构类型的5条常用命令