- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
信号因实现而异。 APUE(Unix环境中的高级编程)中有一些不错的表格,例如第2版第292页的“图10.1 UNIX系统信号”。
让我们以 SIGWAITING
为例。信号出现in the documentation as int
,但大多数实现似乎使用 #define
而不是 const int
。
但是,该标准是否规定在任何地方都可以依赖#define
信号?或者我可以根据这样一个事实来假设它:几乎每个现有的实现都使用#define
。或者这完全是一个错误的假设?
基本原理是这样的:如果我可以依赖使用#define
,我可以使用#ifdef
来隐藏不使用的实现中更奇特的信号它。对于 const int 常量名称,我不知道是否有类似的机制可以允许做出此编译时决策。
最佳答案
请参阅 POSIX(2008、2013)规范 <signal.h>
。其中部分内容是:
The
<signal.h>
header shall define the following macros that are used to refer to the signals that occur in the system. Signals defined here begin with the letters SIG followed by an uppercase letter. The macros shall expand to positive integer constant expressions with type int and distinct values. The value 0 is reserved for use as the null signal (seekill()
). Additional implementation-defined signals may occur in the system.…
The following signals shall be supported on all implementations…
后面是信号名称表。您链接到的版本是该标准的 2004 版,对于宏的信号名称并没有那么明确,但更高版本将现有实践编入法典。
因此,为了符合 POSIX,信号名称应为 #define
'd。
关于c - 所有 POSIX/SUS 信号都是 #define 是给定的还是假设的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21485349/
这个问题涉及需要在 POSIX/SUS 标准的必需 header 中定义的各种类型。 有些类型需要在许多头文件中定义,我想知道实现这一点的正确且合规的方法是什么。 例如,查看 header 规范:
信号因实现而异。 APUE(Unix环境中的高级编程)中有一些不错的表格,例如第2版第292页的“图10.1 UNIX系统信号”。 让我们以 SIGWAITING 为例。信号出现in the docu
我正在致力于将 bash 脚本移植到 SUS/POSIX 兼容的 shell。我自己能够消除大部分的羞辱,但目前我只能坚持最后一个。 该脚本用于根据 cron.d 目录中的文件生成 crontab,并
有时我需要编写低级多平台 C/C++ 代码,以便预处理器环境 macroses 派上用场。但是是否有某种方法或单个互联网资源或在 man 中我可以轻松找到一个标准,在该标准中首次引入特定的 Unix
我是一名优秀的程序员,十分优秀!