Hi!
Here is a real C++ noob question. I want to define a global variable that is changable with a slider and accessible to all objects in my project. I tried it like this:
Qt Code:
#ifndef CONSTANTS_H #define CONSTANTS_H #define PI 3.14159265358979323846 #define G 9.81 #define FPS 90 extern double GAMMA; double GAMMA = 0.01; #endif // CONSTANTS_HTo copy to clipboard, switch view to plain text mode
Until now I only had the #defined globals and it worked great by including constants.h everywhere I needed them. Now I have a new parameter GAMMA, which is not only global, but also needs to be changed from time to time.
Well, this doesn't work, otherwise I wouldn't be asking. I get a compile error:
It's not that the name GAMMA is already taken. I tried renaming it to something really special and it didn't help. I would like to keep all globals, constant or not, in one header file. What am I doing wrong?debug/passivewalker.o: In function `ZN5QLineC1Eiiii':
c:/Qt/4.4.3/include/QtGui/../../src/gui/painting/qpainter.h.data+0x0): multiple definition of `GAMMA'
debug/stickman.o:C:/Qt/2009.03/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/locale_facets.tcc:2497: first defined here
collect2: ld returned 1 exit status
Thanks
Cruz
Bookmarks