什么FILE结构成员意味着什么用C? [英] What do FILE struct members mean exactly in C?

查看:209
本文介绍了什么FILE结构成员意味着什么用C?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

typedef struct _iobuf{
    char*   _ptr;
    int     _cnt;
    char*   _base;
    int     _flag;
    int     _file;
    int     _charbuf;
    int     _bufsiz;
    char*    _tmpfname;
   }  FILE;

我尝试打印他们,但我不明白他们的意思。
在这里,究竟是在C FILE关键词?他说, 有些人认为,没有人在他们的脑子应该利用这种结构的内部机制。但他没有解释他们的意思。

I try to print them but I don't understand what they mean. Here What exactly is the FILE keyword in C? He said "Some believe that nobody in their right mind should make use of the internals of this structure." but he didn't explain what they mean.

推荐答案

看源$ C ​​$ C的实现,如果你想知道这些字段的含义基于文件的IO调用系统的运行时库。

Look at the source code for your system's run-time libraries that implement the FILE-based IO calls if you want to know what those fields mean.

如果你写code,它依赖于使用这些领域,这将是不可移植的最好,完全错误的在最坏的情况,肯定容易折断。例如,在Solaris中有只是正常运行时的libc库中的文件结构至少有三个不同的实现,这些实现之一(64位的)是不透明的,你不能访问的任何字段。简单地改变编译器标志变化的文件结构中的code使用。

If you write code that depends on using those fields, it will be non-portable at best, utterly wrong at worst, and definitely easy to break. For example, on Solaris there are at least three different implementations of the FILE structure in just the normal libc runtime libraries, and one of those implementations (the 64-bit one) is opaque and you can't access any of the fields. Simply changing compiler flags changes which FILE structure your code uses.

而这只是一个一个版本的单一操作系统。

And that's just one one version of a single OS.

这篇关于什么FILE结构成员意味着什么用C?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆