gpt4 book ai didi

c++ - arch_prtcl C++ 原型(prototype)

转载 作者:太空宇宙 更新时间:2023-11-04 13:30:19 24 4
gpt4 key购买 nike

对于 arch_prctl 这个人 page状态:

As of version 2.7, glibc provides no prototype for arch_prctl(). You have to declare it yourself for now. This may be fixed in future glibc versions.

用 clang 编译 C 程序运行良好但会抛出警告

warning: implicit declaration of function 'arch_prctl' is invalid in C99

但是尝试用 clang++ 编译 C++ 失败了

error: use of undeclared identifier 'arch_prctl'

那么,我该如何自己声明所需的原型(prototype)呢?

最佳答案

我花了一些时间才意识到,glibc 可能根本不支持 arch_prctl。所以必须自己做相应的系统调用:

#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>

int arch_prctl(int code, unsigned long addr)
{
return syscall(SYS_arch_prctl, code, addr);
}

关于c++ - arch_prtcl C++ 原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31744307/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com