I know I'm not supposed to use them, but they make life easier...
Well, no so easy... :
I started by writting in a file called globalVariables.h:
Qt Code:
#ifndef GLOBALVARIABLES_H #define GLOBALVARIABLES_H 0 int ** Log; #endifTo copy to clipboard, switch view to plain text mode
Then in maze.cpp and in mazeform.ui.h I did #include "globalVariables.h"
(I tried to add globalVariables.h in maze.pro, then I removed it, it doesn't
change anything). I get
g++ -o maze .obj/maze.o .obj/mazebox.o .obj/main.o .obj/lcdrange.o .obj/mazeform.o .obj/qmake_image_collection.o .obj/moc_lcdrange.o .obj/moc_maze.o .obj/moc_mazeform.o -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
.obj/mazeform.o(.bss+0x0): multiple definition of `Log'
.obj/maze.o(.bss+0x0): first defined here
collect2: ld returned 1 exit status
make: *** [maze] Error 1
BUT when I remove the #include directive from mazeform.ui.h, I get
mazeform.ui.h: In member function `virtual void MazeForm::fileSave()':
mazeform.ui.h:72: error: `GLOBALVARIABLES_H' undeclared (first use this
function)
mazeform.ui.h:72: error: (Each undeclared identifier is reported only once for
each function it appears in.)
mazeform.ui.h:73: error: `Log' undeclared (first use this function)
make: *** [.obj/mazeform.o] Error 1
(I was also testing to see if it knew GLOBALVARIABLES_H)
AND when I remove the #include from maze.cpp I get
maze.cpp: In member function `void MazeField::intialiseLog()':
maze.cpp:89: error: `Log' undeclared (first use this function)
maze.cpp:89: error: (Each undeclared identifier is reported only once for each
function it appears in.)
make: *** [.obj/maze.o] Error 1
Please tell me WHERE I'm supposed to #include "globalVariables.h" so that
all files have acces to it and it doesn't get included too often (ignoring the
preprocessing directives?)???.
Thank you
Mariane
Bookmarks