[英]Are all c libraries in c++ too
您好,我正在 visual studio 2022 上運行這段代碼。但是它說#include <unistd.h>
無法打開。 基本上它是我在 cpp 環境中運行的 c 代碼。
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
int id;
id = fork();
if (id < 0) {
printf(" Error \n");
return (1);
}
else if (id == 0)
printf("Child\n");
else
printf("Parent \n");
return 0;
}
所以我很困惑,可能所有 c 庫都沒有包含在 cpp 語言中。 如果我在 gcc 中運行這個程序,這是說 fork in not defined???
我嘗試在 dev cpp、visual studio 2022 和 gcc 中的三個編譯器上運行此代碼,但已拋出錯誤。
unistd.h 是一個 unix 文件,如果你在 Windows 上運行它,你不能使用那個 header 文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.