gpt4 book ai didi

clone() 函数隐式声明

转载 作者:太空狗 更新时间:2023-10-29 12:32:07 26 4
gpt4 key购买 nike

我正在使用函数 clone()创建线程。问题是我在编译期间遇到此错误:

implicit declaration of function ‘clone’ [-Wimplicit-function-declaration]

我包括了 <linux/sched.h> .可能是什么问题?

最佳答案

在源文件的顶部添加以下行

#define _GNU_SOURCE  
#include <linux/sched.h> /* or #include <sched.h> */

_GNU_SOURCE是一个功能测试宏

功能测试宏允许程序员在编译程序时控制系统头文件公开的定义。为了有效,必须在包含任何头文件之前定义功能测试宏。这可以在编译命令 ( cc -DMACRO=value ) 或 #define 中完成。 -ing #include 之前源代码中的宏-ing 任何 header 。

关于clone() 函数隐式声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23579354/

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