First of all, i have two codes:
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
Editor.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
But my compiler tells me that it doesn’t know Editor, in ManagedGlobalsDeclaration. The class ManagedGlobals is declared in ManagedGLobalsDeclaration.h, and is then(somewhere else) actually defined, so thats why i make a header just to use the extern. But why doesn’t it recognize Editor?
Error 29 error C2065: 'Editor' : undeclared identifier
You have a circular include. Try using a forward declaration instead: