我正在使用 Visual C++ Express 创建一个 DLL,在
以下是我的文件结构:
Required.h
中声明extern ValveInterfaces* VIFace
时,编译器告诉我 ValveInterfaces
未定义。(我想将VIFace
暴露给包括Required.h
在内的任何文件)以下是我的文件结构:
DLLMain.cpp
#include "Required.h" //required header files, such as Windows.h and the SDK
ValveInterfaces* VIFace;
//the rest of the file
Required.h
#pragma once
//include Windows.h, and the SDK
#include "ValveInterfaces.h"
extern ValveInterfaces* VIFace; //this line errors
ValveInterfaces.h
#pragma once
#ifndef _VALVEINTERFACES_H_
#define _VALVEINTERFACES_H_
#include "Required.h"
class ValveInterfaces
{
public:
ValveInterfaces(void);
~ValveInterfaces(void);
static CreateInterfaceFn CaptureFactory(char *pszFactoryModule);
static void* CaptureInterface(CreateInterfaceFn fn, char * pszInterfaceName);
//globals
IBaseClientDLL* gClient;
IVEngineClient* gEngine;
};
#endif
ValveInterfaces.h
和Required.h
的循环包含引起的),但它可能会导致类似的问题。 - Mike Seymour