c++ - 玉米片实验中“*”标记之前的预期初始化程序
问题描述
这是警报类的定义:(我对问题进行了一些更改)
//Alarm.h
#pragma once
#include "system.h"
#include "list.h"
//#include "../machine/timer.h"
//void timerhandler(int dummy);
void check(int which);
class Alarm
{
public:
Alarm();
~Alarm();
void Pause(int howLong);
List *queue;
//Timer *timer;
int waiters;
void CheckIfDue(); // Check if an interrupt is supposed
// to occur now
static void new_instance();
static Alarm *instance;
};
alm 的声明位于名为 system.cc 的文件中。
//system.cc
#include "copyright.h"
#include "system.h"
...
Alarm *alm;
错误发生在 system.h 中,我在其中声明了 Alarm.h。
//system.h
#include "copyright.h"
#include "utility.h"
#include "thread.h"
#include "scheduler.h"
#include "interrupt.h"
#include "stats.h"
#include "timer.h"
#include "Alarm.h"
// Initialization and cleanup routines
extern void Initialize(int argc, char **argv); // Initialization,
// called before anything else
extern void Cleanup(); // Cleanup, called when
// Nachos is done.
extern Thread *currentThread; // the thread holding the CPU
extern Thread *threadToBeDestroyed; // the thread that just finished
extern Scheduler *scheduler; // the ready list
extern Interrupt *interrupt; // interrupt status
extern Statistics *stats; // performance metrics
extern Timer *timer; // the hardware alarm clock
extern Alarm *alm;
33 extern Alarm *alm;
../threads/system.h:33: error:expected initializer before ‘*’ token
似乎无论我把代码“extern Alarm *alarm;”放在哪里,都会发生错误。
解决方案
我找到了原因。它似乎是由相互包含的头文件引起的(system.h&Alarm.h)。一旦我将“外部警报 *警报”放入 Alarm.cc,错误就会消失。但是我仍然没有找到有关该错误的更多详细信息。如果您能给我一些想法,我将不胜感激。
推荐阅读
- amazon-web-services - 您能否在 CloudFormation 中为 AWS 特定参数提供可选参数?
- django - Django模型形式:m2m的反面不保存
- php - 我需要帮助才能在 WordPess 中使用以下代码进行 Paypal 自适应付款
- php - tinyint 类型的 MySQL 字符串值 - PHP PDO 构建
- javascript - 如果使用 jQuery/javascript ajax 在响应中找到“Content-Disposition”,则自动下载文件
- android - 具有自定义视图的 objectanimator
- excel - 将excel中的日期格式从dd.mmm转换为dd.mm
- python - 条件 If 语句:如果值包含字符串,则设置另一列等于字符串
- selenium - 无法创建托管在 docker 上的 firefox 部分 selenium 网格
- java - Java中的Akka FSM