其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Learning boost SP 1 -- 什么是complete type

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

在学习boost的过程中,我们发现在boost的文档中,多处提及了complete type和incomplete type。到底什么是complete type呢?经过我查找msdn,终于发现了,原来complete type是编译器能够确定类型大小的类型,incomplete type是编译器不能确定类型大小的类型。incomplete type有:

  • 没有确定成员的struct
  • 没有确定成员的union
  • 没有确定大小的数组

看看msdn吧:

C Language Reference  

Incomplete Types

An incomplete type is a type that describes an identifier but lacks information needed to determine the size of the identifier. An "incomplete type" can be:

  • A structure type whose members you have not yet specified.
  • A union type whose members you have not yet specified.
  • An array type whose dimension you have not yet specified.

The void type is an incomplete type that cannot be completed. To complete an incomplete type, specify the missing information. The following examples show how to create and complete the incomplete types.

  • To create an incomplete structure type, declare a structure type without specifying its members. In this example, the ps pointer points to an incomplete structure type called student.
    struct student *ps;
  • To complete an incomplete structure type, declare the same structure type later in the same scope with its members specified, as in
    struct student
    {
        int num;
    }                   /* student structure now completed */
  • To create an incomplete array type, declare an array type without specifying its repetition count. For example:
    char a[];  /* a has incomplete type */
  • To complete an incomplete array type, declare the same name later in the same scope with its repetition count specified, as in
    char a[25]; /* a now has complete type */



相关文章

相关软件