|
Multipule definition of timers |
sicgamemaker
Member #1,365
June 2001
|
i have 2 .cpp (engine.cpp, main.cpp) files in myproject that use these timers and when i include the .h file, i get redefinition errors for the timers how do i get these timers to (or at least the variables) to be used in both cpp files? this is the basic layout
-------------- -------------------- -------------- _______________________ |
kdevil
Member #1,075
March 2001
|
If engine.h includes timers.h, do you have to do ----- |
sicgamemaker
Member #1,365
June 2001
|
yeah, if i dont, i cant access those variables from main.cpp because im using a multiple file project in MSVC++ 6 _______________________ |
DanTheKat
Member #1,990
March 2002
|
Heh. Allegro.h #includes timer.h.
--- |
orz
Member #565
August 2000
|
Generally, functions shouldn't be in .h files, unless they're inline functions. And callbacks shouldn't be inline functions. Also, variables declared in .h files should be labeled extern, and have a .c or .cpp also declare a variable of the same name without the extern. Otherwise, ever .c or .cpp files that includes those .h files will create a variable or function by that name, and all the variables and functions will conflict with each other. |
sicgamemaker
Member #1,365
June 2001
|
ok, so i shoudl seperate the variable's from the declaration of the timer functions, and stick teh timer functions in a timers.cpp file... and the variables should work like this: timers.h timers.cpp _______________________ |
orz
Member #565
August 2000
|
Correct. Another thing: I'm not sure, but I seem to recall floating point numbers not working from inside of timer functions on some platforms. If you don't need portability, maybe it's not an issue. |
|