DebugUtil.hJeden lub więcej mnożyć zdefiniowane symbole znaleźć
#ifndef DEBUG_UTIL_H
#define DEBUG_UTIL_H
#include <windows.h>
int DebugMessage(const char* message)
{
const int MAX_CHARS = 1023;
static char s_buffer[MAX_CHARS+1];
return 0;
}
#endif
Kiedy próbuję uruchomić to uzyskać ten błąd:
Terrain.obj : error LNK2005: "int __cdecl DebugMessage(char const *)" ([email protected]@[email protected]) already defined in Loodus.obj
Renderer.obj : error LNK2005: "int __cdecl DebugMessage(char const *)" ([email protected]@[email protected]) already defined in Loodus.obj
test.obj : error LNK2005: "int __cdecl DebugMessage(char const *)" ([email protected]@[email protected]) already defined in Loodus.obj
C:\Users\Tiago\Desktop\Loodus Engine\Debug\Loodus Engine.exe : fatal error LNK1169: one or more multiply defined symbols found
Ale dlaczego tak się dzieje? Mam #ifndef #define i #endif w nagłówku, więc wiele definicji nie powinno się zdarzyć
możliwym duplikat [Błąd linku z naprawdę prostymi funkcjami C++ na pliku .h] (http://stackoverflow.com/questions/6424911/link-error-with-really-simple-functions-c-on-h-file) –
@ Armen: To jest jak Hame, że odpowiedzi na to pytanie są znacznie lepsze :( –