gpt4 book ai didi

c - vfork() 隐式声明

转载 作者:太空宇宙 更新时间:2023-11-04 08:35:01 25 4
gpt4 key购买 nike

我在 C 中使用 vfork() 工作。我的程序运行良好,但我收到有关隐式声明的警告。

我的代码:

if(vfork()==0){
...
}

我的警告是:

函数“vfork”的隐式声明 [-Wimplicit-function-declaration] if(vfork()==0){^

我包括那些:

#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>

如果我使用 fork() 而不是 vfork() 警告消失了。 Soo 问题只是我程序中的 vfork() 。我不知道这是什么意思,也不知道我该如何解决。

最佳答案

您需要包含这两个 header :

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

此外,在程序的开头添加这一行:

#define _BSD_SOURCE 

关于c - vfork() 隐式声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26636627/

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