为什么会重定义呢?
stdafx.h 包含了
#include "Global.h"
#include "externs.h"
Global.h :
#pragma once
LPWSTR pSysDir = NULL;
LPWSTR pAppDir = NULL;
externs.h:
#pragma once
extern LPWSTR pSysDir;
extern LPWSTR pAppDir;
连接的时候就出现了:
inject.obj : error LNK2005: "unsigned short * pSysDir" (?pSysDir@@3PAGA) 已经在 stdafx.obj 中定义
inject.obj : error LNK2005: "unsigned short * pAppDir" (?pAppDir@@3PAGA) 已经在 stdafx.obj 中定义
[解决办法]
那你就不要在头文件中定义
extern LPWSTR pSysDir;
extern LPWSTR pAppDir;
[解决办法]