Global Class Object Extern Fails
Hi,
So I have tried to follow the tutorials on how to utilize a global class object. I have, in global.h,
#include "ABV.h"
#include "ABVstate.h"
extern ABV *Veh;
extern ABVstate *VehState;
and in global.cpp
#include "../include/global.h"
ABV *Veh = NULL;
ABVstate *VehState = NULL;
and I am compiling the object file global.o and getting the error:
in global.h:20 'expected initializer before '*' token'
Am I off with this?
I have also tried adding "using namespace std;" to the .h file with the same error
Full files:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#ifndef __GLOBAL_H
#define __GLOBAL_H
#include "ABV.h"
#include "ABVstate.h"
/********** Thread Priorities **********/
// from main.cpp
#define COMM_PRIORITY 35
#define CTRL_PRIORITY 30
#define EST_PRIORITY 30
// and rates in hertz
#define COMM_SCHEDULER_RATE 50
#define CTRL_SCHEDULER_RATE 50
#define EST_SCHEDULER_RATE 50
using namespace std;
extern unsigned killABV;
extern ABV *Veh;
extern ABVstate *VehState;
extern int initializeGlobals();
extern int terminateGlobals();
|
and the externs are defined as posted in global.cpp.
The part of the makefile that complains is
1 2
|
$(BIN_OBJ_DIR)/ABVCtrl.o: $(INC_DIR)/ABV.h $(INC_DIR)/ABVstate.h $(INC_DIR)/global.h $(INC_DIR)/ABVControl.h $(INC_DIR)/ABVCtrl.h $(SRC_DIR)/ABVCtrl.cpp
$(CXX) -o $@ $(CXXFLAGS) $^
|
Thanks!
Last edited on
If your global.h is exactly that then an #endif
is missing
The #endif is included in the file-just didn't make it in the copy/paste-my oversight.
I have also tried adding
using namespace std;
in which the compiler gives the same issue with
extern ABV *Veh
I have also tried it doing
1 2
|
extern std::ABV *Veh;
extern std::ABVstate *VehState
|
In which case the compiler gives the same complaint about both lines.
Last edited on
std has nothing to do with 'ABV'. Since I don't know what ABV is I can't tell what's the problem is. Often it's missing semicolon or bracket
Topic archived. No new replies allowed.