小编Aye*_*Jay的帖子

函数"等待"的隐含声明

我收到警告>隐式声明函数'wait'<当我运行程序它正常工作时,我想明白为什么我收到这个警告?

提前致谢

编辑:我忘了添加包含的库

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


void create (char* program, char** arg_list)
{
  /* put your code here */
  pid_t childPid;
  int status;

  if((childPid = fork()) < 0){
    printf("Failed to fork() --- exiting...\n");
    exit(1);
  }
  else if (childPid == 0){ // --- inside the child process
    if(execvp(program, arg_list) < 0){ // Failed to run the command
      printf("*** Failed to exec %s\n", program);
      exit(1);
    }
  }
  else{ // --- parent process
    while(wait(&status) != childPid)
      printf("...\n");
  } …
Run Code Online (Sandbox Code Playgroud)

c pid wait

10
推荐指数
2
解决办法
3万
查看次数

在此范围内未声明"变量"

当我尝试编译我的类时,我收到此错误.我确保有功能原型和变量正确启动,希望有人可以帮助我找出问题所在

g++ -c main.cc
g++ -c BankControl.cc
g++ -c Bank.cc
g++ -c Account.cc
g++ -c View.cc
g++ -c AcctList.cc
g++ -c Customer.cc
g++ -c CustArray.cc
g++ -c Transaction.cc
Transaction.cc: In function ‘int getTransID()’:
Transaction.cc:18:34: error: ‘transID’ was not declared in this scope
 int getTransID()        { return transID;  }
                                  ^
Transaction.cc: In function ‘TransType getTType()’:
Transaction.cc:19:34: error: ‘tType’ was not declared in this scope
 TransType getTType()    { return tType;    }
                                  ^
Transaction.cc: In function ‘TransState getTState()’:
Transaction.cc:20:34: error: ‘tState’ was not …
Run Code Online (Sandbox Code Playgroud)

c++

0
推荐指数
1
解决办法
457
查看次数

标签 统计

c ×1

c++ ×1

pid ×1

wait ×1