linux FILE 类型.

  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行的前面.

时间: 2024-08-19 04:01:51

linux FILE 类型.的相关文章

【转】每天一个linux命令(24):Linux文件类型与扩展名

原文网址:http://www.cnblogs.com/peida/archive/2012/11/22/2781912.html Linux文件类型和Linux文件的文件名所代表的意义是两个不同的概念.我们通过一般应用程序而创建的比如file.txt.file.tar.gz ,这些文件虽然要用不同的程序来打开,但放在Linux文件类型中衡量的话,大多是常规文件(也被称为普通文件). 一. 文件类型 Linux文件类型常见的有:普通文件.目录文件.字符设备文件和块设备文件.符号链接文件等,现在我

Linux文件类型与扩展名

Linux文件类型和Linux文件的文件名所代表的意义是两个不同的概念.我们通过一般应用程序而创建的比如file.txt.file.tar.gz ,这些文件虽然要用不同的程序来打开,但放在Linux文件类型中衡量的话,大多是常规文件(也被称为普通文件). 一. 文件类型 Linux文件类型常见的有:普通文件.目录文件.字符设备文件和块设备文件.符号链接文件等,现在我们进行一个简要的说明. 1. 普通文件 我们用 ls -lh 来查看某个文件的属性,可以看到有类似-rwxrwxrwx,值得注意的是

Unix/Linux文件类型及访问权限

在Linux系统中,有7种文件类型. 普通文件 (regular file) 目录文件 (directory) 链接文件 (symbolic link) 管道文件 (FIFO) 套接字文件 (socket) 字符设备文件 (character device) 块设备文件    (block device) 在Solaris上,还有一种文件类型, 叫做door文件. 而一个文件的Unix访问权限,包括12位,通常用4个8进制位表示, 标志 八进制值 含义 S_ISUID 04000 set use

Linux文件类型及颜色标识整理

Linux文件类型及颜色标识整理 缩 写 文件类型 英 文 颜  色 - 普通文件 Regular  file 白色 d 目录文件 Dirrectory  file 蓝色 b 块特殊文件 block  special file 黄色 c 字符设备文件 character  special file 黄色 p 先进先出管道文件 FIFO 暗黄色 s 套接字文件 Socket 粉红色 l 符号链接文件 sysmnolic  link 浅绿色 图示: 上图内容所有文件均是自行创建或其他目录拷贝而来,只

Linux系统文件类型

Linux系统文件类型有:   -:普通文件 d:目录文件(directory) b:块设备文件(block) c:字符设备文件(character) l:符号链接文件(symbolic link file) p:管道文件(pipe) s:套接字文件(socket)

Linux文件类型分类

Linux文件一般是用一些相关的应用程序创建,比如图像工具.文档工具.归档工具... .... 或 cp工具等.linux文件的删除方式是用rm 命令. Linux文件类型:Linux文件类型和Linux文件的文件名所代表的意义是两个不同的概念.我们通过一般应用程序而创建的比如file.txt.file.tar.gz ,这些文件虽然要用不同的程序来打开,但放在Linux文件类型中衡量的话,大多是常规文件(也被称为普通文件). Linux文件类型常见的有:普通文件.目录.字符设备文件.块设备文件.

每天一个linux命令(23):Linux文件类型与扩展名

Linux文件类型和Linux文件的文件名所代表的意义是两个不同的概念.我们通过一般应用程序而创建的比如file.txt.file.tar.gz ,这些文件虽然要用不同的程序来打开,但放在Linux文件类型中衡量的话,大多是常规文件(也被称为普通文件). 一. 文件类型 Linux文件类型常见的有:普通文件.目录文件.字符设备文件和块设备文件.符号链接文件等,现在我们进行一个简要的说明. 1. 普通文件 我们用 ls -lh 来查看某个文件的属性,可以看到有类似-rwxrwxrwx,值得注意的是

Linux file&echo命令

file:查看文件内容类型的 file [FILE]....可以跟多个文件 echo:回显 echo [SHORT-OPTION]... [STRING]... -n:不进行自动换行 -e:让转义符生效 (\n     new line 换行) (\t     horizontal tab 制表符) (\v     vertical tab) (\b     backspace 删除前面的字符) STRING可以使用引号,单引号和双引号均可用: 单引号:强引用,变量引用不执行替换 ~]#echo

如何查看linux文件系统类型?

以往使用的linux命令,一定要善于总结. 如何查看linux文件系统类型? 1. df 命令报告文件系统磁盘空间利用率,使用-T选项显示特定的磁盘分区的文件系统类型,-h人类可读方式显示. [[email protected] ~]# df -Th Filesystem     Type   Size  Used Avail Use% Mounted on /dev/sda2      ext4    19G   12G  6.3G  65% / tmpfs          tmpfs  4