小编att*_*lee的帖子

致命错误:在 mac osx 10.10.5 下找不到“common.h”文件

我按照操作系统:三件简单的书,介绍章节中的代码,

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <assert.h>
#include "common.h"

int
main(int argc, char *argv[])
{
  if (argc != 2)
  {
    fprintf(stderr, "usage: cpu <string>\n");
    exit(1);
  }
  char *str = argv[1];
  while(1)
  {
    Spin(1);
    printf("%s\n", str);
  }
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我尝试时gcc -o cpu cpu.c -Wall

错误出来了:fatal error: 'common.h' file not found

我试过从这个链接下载common.h ,并把这个文件和cpu.c放在一起,但它不起作用,错误信息:

cpu.c:8:1: error: conflicting types for 'main'
main(int argc, char *argv[])
^
./common.h:86:13: note: previous declaration is …
Run Code Online (Sandbox Code Playgroud)

c c++ macos

6
推荐指数
1
解决办法
4317
查看次数

标签 统计

c ×1

c++ ×1

macos ×1