您的位置:首页 > 其它

C 语言中一些非常用知识点 备忘录

2013-11-01 08:48 357 查看
在看一些C语言资料时,总是碰到一些非常见的知识点,看过就忘,这里把他们记录下来。

7. ----> 什么是Designated initializers for aggregate types (C only),看了IBM的解释更易懂,

Designated initializers, a C99 feature, aresupported for aggregate types, including arrays, structures, and unions. Adesignated initializer, ordesignator, points outa
particular element to be initialized. Adesignatorlist is a comma-separated list of one or more designators. A designatorlist followed by an equal sign constitutes adesignation.

Elements within an aggregate can be initialized in any order.
The initializer list can omit elements that are declared anywhere in theaggregate, rather than only at the end.Elements that areomitted are initialized as if they are static objects: arithmetic types areinitialized to 0; pointers are initialized to
NULL.
Where inconsistent or incomplete bracketing of initializers for multi-dimensionalarrays or nested aggregates may be difficult to understand, designators canmore clearly identify the element or member to be initialized.

下面举例:

struct xyz {
       int a;
       int b;
       int c;
       } klm = { .a = 99, .c = 100 };

int aa[4] = { [2] = 3, [1] = 6 };
static short grid[3] [4] = { [0][0]=8,[0][3]=1,
                             [2][0]=9, [2][1]=3,
                             [2][2]=1, [2][3]=1 };


6.---->C99 permits declarations anywhere within a block. Previous Versions of C permitted them only before the first statment. 参考(C语言参考手册) chapter 4.3

5.----> Statement labels have function scope. 意思就是说用于goto 语句的标号的作用范围是一个函数内。-reference 《C A reference manual》chapter:4.2.1;8.10

4.---->什么是 incomplete type?

如果有如下定义:

structure foo;

structure foo *pFoo;

then the expression *pFoo is an experession with incomplete type,because the type srtucture foo have not been fully defined.

3.----> 什么是 qualified type,什么是 fully qualified type?

2.---->The C99 function specifier(inline) can appear only on function declarations. -----reference 《C A reference manual》(C语言参考手册) chapter 4.1

1.---->声明一个东西时(一个变量,一个类型,一个函数等),我们需要declaration-specifiers,总共有如下四种specifiers: 参考(C语言参考手册) chapter 4

storage-class-specifier, type-specifier, type-qualifier, function-specifier

其中 storage-class-specifier 有:auto, extern,register,static,typedef

其中Type specififiers 主要提供数据类型信息,有 enumeration,floating-point,interger,structure,typedef-name,union,void

其中type qualitifer 主要是提供更多额外的信息,尤其是在accessing objects of the type through lvalues. 有:const,volatile,restrict.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: