c - 这样的定义 "#define __arch_swab32 __arch_swab32"是什么意思?

标签 c linux

<分区>

在/usr/include/asm/swab.h 中,我找到了以下代码:

static __inline__  __u32 __arch_swab32(__u32 val)
{
    __asm__("bswapl %0" : "=r" (val) : "0" (val));
    return val;
}
#define __arch_swab32 __arch_swab32

最后一行是什么意思,定义一个名称本身?

最佳答案

这叫做 self-referentitial macro :

One common, useful use of self-reference is to create a macro which expands to itself. If you write

 #define EPERM EPERM

then the macro EPERM expands to EPERM. Effectively, it is left alone by the preprocessor whenever it's used in running text. You can tell that it's a macro with #ifdef. You might do this if you want to define numeric constants with an enum, but have #ifdef be true for each constant.

关于c - 这样的定义 "#define __arch_swab32 __arch_swab32"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45857532/

相关文章:

c - Bash shell程序启动C程序

c++ - 在 C 中使用 C++ 结构

linux - 如何为 RHEL 6 找到 libstdc++.so.6 : that contain GLIBCXX_3. 4.19?

带管道的 c 程序执行 "ps aux | grep firefox | tee processes.txt"

Python SIGINT 不终止调用 shell

c - 这个 C 函数返回什么?

c - 使用带有指针的结构读取二进制文件中的某个位置

可以映射零页或写入地址零吗?

创建一个 GUI 来绘制 Linux 中的 CPU 使用率

linux - TLB 转换与缓存