C++ using gcroot in header file for managed class

I'm redesigning my code, so its a mess for now, mostly because this wrapper wont work in header files:

1
2
3
4
5
6
7
8
9
10
11
#include "Editor.h"
#include <vcclr.h>

using namespace System;
using namespace Cube3D;

class ManagedGlobals
{
public:
    gcroot<Editor^> MainEditor;
};


As you can see i have defined a class called ManagedGlobals which contains a public variable. Which is actually a managed variable, because its a .net form, well, the "Editor^" is a managed .net form. This method worked perfect when doing it in a .cpp file, but suddenly i needed this variable else than in that cpp file. So my brain told me: "Why not put that stuff in a header file, and put some include guards, so i can include it?" And... So i did. But, suddenly it couldn't understand what Editor^ was:

'Editor' : undeclared identifier

Which i find very weird, because Editor was a part of the namespace Cube3D, and in the Editor.h. I've already tried to say:

gcroot<Cube3D::Editor^> MainEditor

But with no luck. And yes, i have already defined the class, ManagedGlobals MG, so that's not the problem.

Any Ideas why gcroot wont work in header files?

Thanks
Ignoring the C++/CLI stuff.

So the Editor class is defined inside Editor.h? Make sure that you did use unique header guards for all your header files.
Yes it is, its a ref class, thats why i'm using gcroot. In the header i use(editor.h) i use #pragma once
All of this worked perfect when doing and defining ManagedGlobals in a cpp file. But when defining it in a header file. It wont work.
bump... Nobody?
Topic archived. No new replies allowed.