Game States & GLUT

mamboJambo
Unregistered
 
Post: #1
Hi, I'm new here. My question is very similar to the thread just below this however it wasn't very explanatory. I have just started a rewrite of a game I entered in uDevGames a few years back that you can see >>here<<. My plan was to make it easier to code by using various game state classes each with their own GLUT callback functions.

How is this possible as you can't pass C++ functions as a C callback?

At the moment I have written static functions that attempt to retrieve the current state from a global stack and propogate the call, however I am just getting a compile error about 'multiple symbols':

Code:
/usr/bin/ld: multiple definitions of symbol _gLoop
/Users/rzepa/CubicsRube2/build/CubicsRube2.build/Debug/CubicsRube2.build/Objects-normal/ppc/main.o private external definition of _gLoop in section (__DATA,__common)
/Users/rzepa/CubicsRube2/build/CubicsRube2.build/Debug/CubicsRube2.build/Objects-normal/ppc/GameLoop.o private external definition of _gLoop in section (__DATA,__common)
collect2: ld returned 1 exit status

Where 'gLoop' is the global class that contains the stack and other global data. I have surrounded all my header files with #ifndef statements so I cannot actually be declaring gLoop more than once. I need to access gLoop from both main.cpp and from GameLoop.cpp obviously.

So what is the best way to combine Game States with GLUT ?

Many thanks for reading this far,

Dave
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Quote this message in a reply
mamboJambo
Unregistered
 
Post: #3
cheers,

making the declaration static worked. damn ambiguous gcc errors Mad Wacko
Quote this message in a reply
Post Reply