Sto creando una DLL utilizzando Visual C++ Express e quando si dichiara extern ValveInterfaces* VIFace
all'interno Required.h
, il compilatore mi sta dicendo che ValveInterfaces
non è definito. (Voglio esporre VIFace
a qualsiasi file incluso Required.h
)extern parola chiave "indicatore di tipo mancante"
Ecco la struttura dei miei file:
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
Schermata di errori: http://i.imgur.com/lZBuB.png
Non si dovrebbero usare nomi riservati per includere guardie. Sebbene non sia la causa del tuo particolare problema (dovuto all'inclusione circolare di 'ValveInterfaces.h' e' Required.h'), può causare [problemi simili] (http://stackoverflow.com/questions/3345159/ in-c-cosa-così-speciale-su-move-h). –