C中不完整类型和对象类型的定义是什么?
C中不完整类型和对象类型的定义是什么?另外,您能否提供一些例子?
ANSI C99 在不同的地方提到了这两种类型类别,尽管我发现很难理解它们的确切含义(没有段落/句子明确定义它们是什么)。
What is the definition of Incomplete Type and Object Type in C? Also, could you provide some examples of each?
ANSI C99 mentions both type categories in various places, though I've found it difficult to understand what each of them means exactly (there is no paragraph/sentence explicitly defining what they are).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让我们看看在线 C 标准(草案 n1256):
不完整类型的示例:
您无法创建不完整类型的实例,但您可以从不完整类型创建指针和 typedef 名称:
要将不完整结构类型转换为对象类型,我们必须定义结构:
Let's go to the online C standard (draft n1256):
Examples of incomplete types:
You cannot create instances of incomplete types, but you can create pointers and typedef names from incomplete types:
To turn the incomplete struct type into an object type, we have to define the struct:
我知道的类型有:
这是一个示例(也在键盘上: http://codepad.org/ bzovTRmz )
struct incomplete
可以在另一个翻译单元中定义(具有确定的大小)。不过这个翻译单元只需要指针The types I know of are:
Here's an example (also on codepad: http://codepad.org/bzovTRmz )
The
struct incomplete
can be defined (with a definite size) in another translation unit. This translation unit only needs the pointer though