[wellylug] C++ Programing Problem
Stephen Judd
sljudd at paradise.net.nz
Sun Sep 7 15:09:42 NZST 2003
On Sun, 2003-09-07 at 13:59, Jethro Carr wrote:
> I think it's a simple solution, but I don't know it....:(
1. Make sure you avoid multiple inclusion
#ifndef JGAME
#define JGAME
#include jgame2d/jgame2d.h
#endif
But I think your real problem is this:
2. Ensure globals in header files are defined with extern, thus:
(in jgame2d.h)
extern int keyboard_state; // this is now simply a declaration
Otherwise, the jolly old compiler sees this:
(in jgame2d.h)
int keyboard_state; // declaring AND defining
as the first definition, and will barf on the "second" one in your .cpp
file.
See http://website.lineone.net/~michael.s.grant/faq.html#multiple-def
HTH
Stephen
More information about the wellylug
mailing list