Hi
I am an experienced C programmer and we have a large app written in C which
I have just recompiled with /clr to start to add in managed code to use .NET
framework and windows forms bit by bit.
I am new to managed C ++(and C++ for that matter).
I am struggling with the fact that it seems you cannot have global managed
variables although I think I understand why you can't.
i.e. if I declare a managed type or class or object as I would a normal C
global variable, I get a complier error:
error C3145 cannot declare a global or static managed type object or an _gc
pointer.
My big problem is I initially want to write some managed C++
functions/classes in a new C++ file which I then want to call from my
existing C code. However these new managed C++ functions need to preserve
data between themselves and between calls from the C code so it seemed
global variables where the ideal solution.
So the scenario is something like
C code
call managed C++ function 1 to initialize data
loop
do some processing
call managed C++ function 2 to work with initialized data
end loop
C++ code
function1
creates some managed data (but where does it preserve this if I cant have
global managed variables)
funtion2
works on previously created managed data
Can anyone advise on how best to tackle this problem.
Thanks
Steve