首先,我有两个代码:
ManagedGlobalsDeclaration.h
#ifndef MGD_H
#define MGD_H
#include "Editor.h"
#include <vcclr.h>
using namespace System;
using namespace Cube3D;
namespace Cube3D {
class ManagedGlobals
{
public:
gcroot<Editor ^> MainEditor;
};
}
#endif
编辑器.h
#ifndef EDITOR_H
#define EDITOR_H
#include "System.h"
#include "AddRenderingPipelineCommand.h"
#include "AddMaterial.h"
#include "P_Material.h"
#include "P_UMesh.h"
#include "Log.h"
#include "ManagedGlobals.h" // <------ Error!
#include <vcclr.h>
namespace Cube3D {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
void LoopRender(void);
void GetRenderingOrder(void);
String^ GetListbox2Item();
TextureObject InstancedTexturing[10];
UMesh InstancedMesh[10];
/// <summary>
/// Summary for Editor
/// </summary>
ref class Editor : public System::Windows::Forms::Form
{
// Bla bla bla....
ManagedGlobals.h
#ifndef MG_H
#define MG_H
#include "ManagedGlobals_Declaration.h"
extern ManagedGlobals MG;
#endif
但是我的编译器在 ManagedGlobalsDeclaration 中告诉我它不知道 Editor。ManagedGlobals 类在 ManagedGLobalsDeclaration.h 中声明,然后(在其他地方)实际定义,所以这就是为什么我制作一个标题只是为了使用 extern。但是为什么它不识别编辑器?
Error 29 error C2065: 'Editor' : undeclared identifier