免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2289 | 回复: 7

[C] 看c99的一点问题 [复制链接]

论坛徽章:
0
发表于 2008-01-31 17:53 |显示全部楼层
8可用积分
实在是不算明白后半部分说的是什么,各位老大帮忙看看啦

5.2.3 Signals and interrupts
1 Functions shall be implemented such that they may be interrupted at any time by a signal,
or may be called by a signal handler, or both, with no alteration to earlier, but still active,
invocations’ control flow (after the interruption), function return values, or objects with
automatic storage duration. All such objects shall be maintained outside the function
image (the instructions that compose the executable representation of a function) on a
per-invocation basis.

最佳答案

查看完整内容

举例说明是怎样进行计数的:int m; /* m 是 int 类型的标识符。尽管 int 属于算术(arithmetic)类型,但是没有被改变(不是 pointer、array、function 中的任何一类),所以计数为 0。 */int* pm; /* pm 是指向 int 的指针(pointer)。int 是算术类型且被改变一次(int => pointer to int),所以计数为 1。 */int** ppm; /* ppm 是指向 int 的指针的指针(int => int* => int**),所以 int 被修改的次数为 2。 */int ma[10]; / ...

论坛徽章:
0
发表于 2008-01-31 17:53 |显示全部楼层
原帖由 zhangjiakouzf 于 2008-1-31 18:01 发表
不好意思,还有这个
— 12 pointer, array, and function declarators (in any combinations) modifying an
arithmetic, structure, union, or incomplete type in a declaration


举例说明是怎样进行计数的:

int m; /* m 是 int 类型的标识符。尽管 int 属于算术(arithmetic)类型,但是没有被改变(不是 pointer、array、function 中的任何一类),所以计数为 0。 */
int* pm; /* pm 是指向 int 的指针(pointer)。int 是算术类型且被改变一次(int => pointer to int),所以计数为 1。 */
int** ppm; /* ppm 是指向 int 的指针的指针(int => int* => int**),所以 int 被修改的次数为 2。 */
int ma[10]; /* ma 是 int 类型的数组(array),所以计数为 1(int => int[10])。 */
int maa[4][5]; /* maa 是 int 类型的数组的数组(int => int[5] => int[4][5]),所以计数为 2。 */
int* pma[10]; /* pma 是指向 int 的指针类型的数组(int => int* => int*[10]),所以计数为 2。 */
int func( void ); /* func 是一个参数为空、返回 int 的函数(int => int()(void)),所以计数为 1。 */
int (*pfunc)( char ); /* pfunc 是一个指向具有一个参数、其类型为 char、且返回类型是 int 的函数的指针(int => int()(char) => int(*)(char)),所以计数为 2。 */
int (*pafunc[10])( char ); /* pafunc 是一个具有 10 个元素的数组,其每个元素的类型是一个指针,每个指针指向一个函数,函数的类型是:具有一个 char 参数、返回 int。其对 int 的修改变化为 int => int()(char) => int(*)(char) => int(*[10])(char),所以计数为 3。 */
int* (*pafunc[10])( char ); /* 除了函数的返回类型变为 int* 外,其余分析与上例相同。只不过计数结果变为 4。 */

论坛徽章:
0
发表于 2008-01-31 18:01 |显示全部楼层
不好意思,还有这个
— 12 pointer, array, and function declarators (in any combinations) modifying an
arithmetic, structure, union, or incomplete type in a declaration

论坛徽章:
0
发表于 2008-01-31 18:21 |显示全部楼层
原帖由 zhangjiakouzf 于 2008-1-31 17:53 发表
实在是不算明白后半部分说的是什么,各位老大帮忙看看啦

5.2.3 Signals and interrupts
1 Functions shall be implemented such that they may be interrupted at any time by a signal,
or may be called ...

我的理解:简单来说就是可重入

论坛徽章:
0
发表于 2008-02-01 09:59 |显示全部楼层
原帖由 lgfang 于 2008-1-31 18:21 发表

我的理解:简单来说就是可重入

谢谢,我也只看明白了这点,后面说的那

论坛徽章:
0
发表于 2008-02-01 13:43 |显示全部楼层
各位老大都回家过年了?

论坛徽章:
0
发表于 2008-02-01 21:25 |显示全部楼层
5.2.3 是对 C 语言中的函数在实现上的要求,主要对象是编译器的编写人员。当然,一般的程序员也可以从这段话中了解 C 函数在使用上给我们的保证。

大意是:

函数应该在实现上做到这样一点:即使函数被信号中断、被信号处理函数调用、或者二者同时发生,(在中断结束之后被中断)函数的控制流程、函数的返回值以及具有自动存储期的对象不应受到影响。每一次函数调用都应该在函数代码区之外实现并维护这样的自动对象。

注意:对于静态对象并没有提出要求,所以上述要求不涉及重入的概念。

论坛徽章:
0
发表于 2008-02-02 10:02 |显示全部楼层
谢谢楼上大哥帮忙!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP