|
试验如下: 新建一个控制台工程,添加三个文件: main.cpp , h.h , another.cpp
--------------h.h 内容如下---------------------------------
#pragma once
#ifndef __h__
#define __h__
typedef unsigned long DWORD;
struct sRHWVertex
{
float _x,_y,_z,_rhw;
DWORD _Color;
float _u,_v;
static const DWORD RHW_FVF;
};
const DWORD sRHWVertex::RHW_FVF = 1;
#endif
--------------main 内容如下------------------------------------------
#include "h.h"
void main()
{
}
--------------another.cpp内容如下-----------------------------------
#include "h.h"
现在链接时报错如下
正在链接...
LINK : warning LNK4075: 忽略“/EDITANDCONTINUE”(由于“/INCREMENTAL:NO”规范)
cpp.obj : error LNK2005: "public: static unsigned long const sRHWVertex::RHW_FVF" (?RHW_FVF@sRHWVertex@@2KB) 已经在 main.obj 中定义
.\Debug/main.exe : fatal error LNK1169: 找到一个或多个多重定义的符号
为什么啊,,难道h.h里面的#pragma once,#ifndef __h__,#define __h__不起作用么?
各位高人,求解~ |
|