加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

sigaction既可以是结构又可以是函数吗?

发布时间:2020-12-15 21:23:16 所属栏目:安全 来源:网络整理
导读:我注意到sigaction被定义为struct和function( http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html): int sigaction(int,const struct sigaction *restrict,struct sigaction *restrict); 使用它的一个例子是: struct sigaction sa;
我注意到sigaction被定义为struct和function( http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html):

int sigaction(int,const struct sigaction *restrict,struct sigaction *restrict);

使用它的一个例子是:

struct sigaction sa;

    /* Set up handler */
    sa.sa_flags = SA_SIGINFO|SA_RESTART;
    sa.sa_sigaction = timer_expiry;

    /* Setup signal watchdog */
    if (sigaction(SIG_WDOG,&sa,NULL) == -1) {
       printf("ERROR: Failed to set wdog signal with %s",strerror(errno));
    }

解决方法

C有几个标识符的名称空间;函数标识符和结构标记标识符位于不同的名称空间中.

(C11,6.2.3 Name spaces of identifiers p1) “If more than one declaration of a particular identifier is visible at any point in a
translation unit,the syntactic context disambiguates uses that refer to different entities.
Thus,there are separate name spaces for various categories of identifiers,as follows:

  • label names (disambiguated by the syntax of the label declaration and use);

  • the tags of structures,unions,and enumerations (disambiguated by following any32) of the keywords struct,union,or enum);

  • the members of structures or unions; each structure or union has a separate
    name space for its members (disambiguated by the type of the
    expression used to access the member via the . or -> operator);

  • all other identifiers,called ordinary identifiers (declared in ordinary declarators or as enumeration constants)

.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读