Multiple Definition Error

Discussion about everything. New games, 3d math, development tips...
Post Reply
Guest

Multiple Definition Error

Post by Guest »

When compiling in Dev-C++ i get a multiple definitions error.
i have made sure the header file has a guard against this, but i still get the error. any ideas?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Could you post exactly what the error looks like, what symbol has multiple definitions?
Guest

Post by Guest »

multiple definition of 'device'
thats all it says.

header:

Code: Select all

#ifndef HEADER_H
#define HEADER_H
IrrlichtDevice *device;
#endif
and then i have a couple of source files that include that file.
shouldn't #ifndef prevent multiple inclusion?
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post by deps »

use

Code: Select all

#ifndef HEADER_H
#define HEADER_H
extern IrrlichtDevice *device;
#endif 
and then in header.cpp or some other cpp file,

Code: Select all

IrrlichtDevice *device;
That should do the trick
Guest

Post by Guest »

awesome! thanks. that did it.
Post Reply