Tôi đang tạo DLL bằng Visual C++ Express và khi khai báo extern ValveInterfaces* VIFace
bên trong Required.h
, trình biên dịch cho tôi biết rằng ValveInterfaces
không được xác định. (Tôi muốn để lộ VIFace
cho bất kỳ tập tin bao gồm Required.h
)từ khóa bên ngoài "thiếu loại thông số"
Dưới đây là cấu trúc của tác phẩm của tôi:
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
Ảnh chụp màn hình của lỗi: http://i.imgur.com/lZBuB.png
Bạn không nên sử dụng tên riêng cho các nhân viên bảo vệ. Mặc dù nó không phải là nguyên nhân của vấn đề cụ thể của bạn (đó là do sự bao gồm vòng tròn của 'ValveInterfaces.h' và' Required.h'), nó có thể gây ra [vấn đề tương tự] (http://stackoverflow.com/questions/3345159/ trong-c-whats-so-đặc biệt-về-di-h). –