【问题标题】:fatal error: asm/atomic.h: No such file or directory on debian10 os致命错误:asm/atomic.h:debian10 os 上没有这样的文件或目录
【发布时间】:2021-08-21 03:47:00
【问题描述】:

我的系统是debian 10,想实现原子操作,但是发现没有原子操作的头文件和API函数。怎么了?原子操作不是内核级函数吗?为什么不呢?

test_atomic.c:

#include <stdio.h>
#include <asm/atomic.h>

int main(void)
{
     printf("test atomic!\n");
     return 0;
}

编译错误:

# gcc test_atomic.c
test_atomic.c:2:10: fatal error: asm/atomic.h: No such file or directory
 #include <asm/atomic.h>
          ^~~~~~~~~~~~~~
compilation terminated.

人工原子 API 错误:

# man atomic_add
No manual entry for atomic_add

【问题讨论】:

    标签: c debian


    【解决方案1】:

    要使用原子操作,您需要使用#include &lt;stdatomic.h&gt;

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-29
    • 2019-09-15
    • 2019-10-10
    • 2017-05-09
    • 2021-05-15
    • 2014-10-31
    • 2022-01-11
    • 2021-09-19
    相关资源
    最近更新 更多