我按照操作系统:三件简单的书,介绍章节中的代码,
#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)