什么是__dirstream,我们在哪里可以找到的定义 [英] what is __dirstream, where can we find the definition

查看:1683
本文介绍了什么是__dirstream,我们在哪里可以找到的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我们在 dirent.h 看到的,是一个typedef:

As we can see in dirent.h, there is a typedef:

typedef struct __dirstream DIR;

它说,它是不透明的用户。而我们甚至不能在GCC头找到它,在 __ dirstream 结构定义只能在glibc的源$ C ​​$ C找到。我很奇怪,为什么这种结构是不透明的(我不认为这是合理的说它prevents用户从直​​接引用,可能是我错了)?有什么收获?

It says it's opaque to users. And we can't find it even in gcc headers, the __dirstream structure definition can only be found in glibc source code. I am wondering why this structure has to be opaque (I don't think it's plausible to say it prevents user from direct reference, probably I am wrong)? What's the catch?

推荐答案

您可以找到实际的定义<一个href=\"http://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/dirstream.h;h=8303f07fab6f6efaa39e51411ef924e712d995e0;hb=fa39685d5c7df2502213418bead44e9543a9b9ec\"相对=nofollow>这里,但作为已经指出你不应该直接访问它。

You can find the actual definition here, but as has been pointed out you're not supposed to access it directly.

它可以在标准库的实现(或同一个库的不同版本)之间随意改变这就是为什么它是隐藏的。

It can change randomly between implementations of the standard library (or different releases of the same library) which is why it's hidden.

您关于通知用户是不够的评论是有点......我不知道,这是一个非常乐观的前景。隐藏定义,使其很难被滥用它,这反过来又使得它更难写违反规范,并包含无谓脆code程序。这是一件好事;你会发现很多软件工程是专门从做他​​们不应该做哪些努力prevent程序员。

Your comment about "informing the user" being enough is a bit ... I don't know, it's a very optimistic outlook. Hiding the definition makes it harder to abuse it, which in turn makes it harder to write programs that violate the specification and contain pointlessly brittle code. It's a good thing; you'll find a lot of software engineering is dedicated to trying to prevent programmers from doing what they're not supposed to be doing.

这又是不一定,因为所有的程序员都傻了,至少这不是我的跨pretation,这是相当因为典型的软件系统的复杂性是非常非常高的,它成为有益的尝试,以减少它只要有可能。信息隐藏在系统降低了复杂性在一个特定的地点的一种方式。

This in turn is not necessarily because "all programmers are stupid", at least that's not my interpretation, it's rather since the complexity of typical software systems is very, very high, it becomes beneficial to try to reduce it whenever possible. Information hiding is one way of reducing the complexity at one particular place in the system.

这篇关于什么是__dirstream,我们在哪里可以找到的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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