Reputation: 21
here's the definition of class Alarm:(I've made some changes to the question)
//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;
};
the declaration of the alm is in a file named system.cc.
//system.cc
#include "copyright.h"
#include "system.h"
...
Alarm *alm;
the error occurs in system.h,in which i've declared 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
it seems wherever i put the code "extern Alarm *alarm;",the error occurs.
Upvotes: 0
Views: 211
Reputation: 21
i've found the reason. it seems to be caused by header files containing each other(system.h&Alarm.h). The error is disappeared once i put the "extern Alarm *alarm" in Alarm.cc. But I still haven't find out more details about the error. I would be appreciate if you can give me some ideas.
Upvotes: 0