0

Whenever I include this file more then once:

#ifndef GFUNC_GAURD
#define GFUNC_GAURD

#ifdef _WIN32
#pragma once
#endif

#include "DarkGDK.h"

// For getting the next unused ID
int GetNextID( )
{
	int temp = 1;
	while( dbObjectExist( temp ) ) // Found an id == temp?
		temp++;
	return temp;
}

#endif // GFUNC_GAURD

I get this error even though I've got include gaurds:

------ Build started: Project: Dark GDK - Test Game, Configuration: Debug Win32 ------
Compiling...
cbEntity.cpp
Main.cpp
Generating Code...
Linking...
cbEntity.obj : error LNK2005: "int __cdecl GetNextID(void)" (?GetNextID@@YAHXZ) already defined in Main.obj
Debug\Dark GDK - Test Game.exe : fatal error LNK1169: one or more multiply defined symbols found
Build log was saved at "file://c:\Documents and Settings\tom\My Documents\Visual Studio 2008\Projects\Project1\Project1\Dark GDK - Test Game\Dark GDK - Test Game\Debug\BuildLog.htm"
Dark GDK - Test Game - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Any help would be appreciated

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

Source code goes in .cpp files, not .h files!

Two files include that .h file, and you have TWO copies of the same function name.
This is what "multiply defined" means - more than ONE.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.