DebugUtil.h一個或多個多重定義符號找到
#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
當我試圖運行此我得到這個錯誤:
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
但是,爲什麼會發生這種情況?我在頭文件中有#ifndef #define和#endif,所以應該不會發生多個定義
可能[鏈接錯誤與真正簡單的函數C++上.h文件]的副本(http://stackoverflow.com/questions/6424911/link-error-with-really-simple-functions-c-on-h-file) –
@ Armen:這是哈姆在_this_問題上的答案好多了:( –