include header file - Printable Version

+- Forums (
+-- Forum: Project (
+--- Forum: Development (
+--- Thread: include header file (/showthread.php?tid=732)

include header file - mpo - 07-20-2007

I have included an header file (and two global variables) into vamosworld.h to control a virtual reality helmet.

using namespace std;

#include "font.h"
#include "ai.h"
#include "trackmap.h"

#include "isense.h"  // Virtual Reality Helmet
//Virtual Reality Helmet variable
I need to use these variables and some functions of the helmet into the files vamosworld.cpp and gui.cpp.
When i try to compile, the compiler don't tell me nothing but the linker give to me a lot of errors like:
"multiple definition of trackerHandle" or "multiple definition of trackerData" (the variables that i have defined).
"undefined references to ISD_OpenTracker" (a function of the helmet library).
Why if i have made the definitions into the #ifndef _VAMOSWORLD_H and vamosworld.h is included into vamosworld.cpp and gui.cpp ?
Down here there's a screenshot of a part of the errors:

- joevenzon - 07-20-2007

Why not put your globals in a C file instead of the header? You can access your globals from other C files using the extern keyword.