470,833 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

C Library using Hans Boehm GC & Managed C++

I am using an OpenSource library I have wrapped in Managed C++.
There is no way I can do without it :-(.

Due to on going problem with this library (which I cannot debug as it is not
in a language supported by VS.NET and as GDB is pitifully inadequate) I plan
to compile this library with Boehm GC support.

I wonder if everything will work allright?

basically what I have looks like:
======================

// == The native library interface (which I will recompile with Boehm GC)

// create and destory pointers
struct TheObject { /* ... */ };
struct TheObject * createObject(char *);
void Destroy(struct* theObj); // presumably with GC enabled does nothing

// use it
struct void AMethod(struct TheObject* char* amethod, int param);

// == my MC++ wrapper
public ref class MyNClass
{
public:
MyClass()
{
pointer = createObject("TheObject");
}
~MyClass()
{
Destroy(pointer);
pointer = NULL;
}
AMethod(int p)
{
aMethod(pointer, "amethod", p);
}
private:
struct TheObject * pointer;
}

=====================

Will this all works gracefully?
comments, tips, links or similar experience?
Jun 8 '06 #1
3 1305
Lloyd Dupont wrote:
I am using an OpenSource library I have wrapped in Managed C++.
There is no way I can do without it :-(.

Due to on going problem with this library (which I cannot debug as it
is not in a language supported by VS.NET and as GDB is pitifully
inadequate) I plan to compile this library with Boehm GC support.

I wonder if everything will work allright?


Who knows :) It really depends on the library. That said, there's no
reason that the CLR and the Boehm GC can't co-exist since they'll each be
managing their own separate heap.

-cd
Jun 8 '06 #2
The problem
this object:
public ref class MyNClass
{
public:
MyClass()
{
pointer = createObject("TheObject");
}
~MyClass()
{
Destroy(pointer);
pointer = NULL;
}
AMethod(int p)
{
aMethod(pointer, "amethod", p);
}
private:
struct TheObject * pointer;
}

is in the managed heap.
hence I'm afraid that Boehm GC won't be able to find the "pointer" pointer
and might free it while it is still in use!

well, I'm going to find out....

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:ug**************@TK2MSFTNGP02.phx.gbl...
Lloyd Dupont wrote:
I am using an OpenSource library I have wrapped in Managed C++.
There is no way I can do without it :-(.

Due to on going problem with this library (which I cannot debug as it
is not in a language supported by VS.NET and as GDB is pitifully
inadequate) I plan to compile this library with Boehm GC support.

I wonder if everything will work allright?


Who knows :) It really depends on the library. That said, there's no
reason that the CLR and the Boehm GC can't co-exist since they'll each be
managing their own separate heap.

-cd

Jun 8 '06 #3
"Lloyd Dupont" <net.galador@ld> wrote in message
news:ub**************@TK2MSFTNGP02.phx.gbl...
The problem
this object:
public ref class MyNClass
{
public:
MyClass()
{
pointer = createObject("TheObject");
}
~MyClass()
{
Destroy(pointer);
pointer = NULL;
}
AMethod(int p)
{
aMethod(pointer, "amethod", p);
}
private:
struct TheObject * pointer;
}

is in the managed heap.
hence I'm afraid that Boehm GC won't be able to find the "pointer" pointer
and might free it while it is still in use!

well, I'm going to find out....


Hmmm.... good point! I hadn't looked at the code you posted closely enough
to appreciate that wrinkle.

-cd
Jun 8 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Pedro Miguel Carvalho | last post: by
43 posts views Thread by Steven T. Hatton | last post: by
8 posts views Thread by HalcyonWild | last post: by
87 posts views Thread by Robert Seacord | last post: by
7 posts views Thread by Ugo Van Noorbeeck | last post: by
7 posts views Thread by Donos | last post: by
3 posts views Thread by Hans-Jürgen Philippi | last post: by
53 posts views Thread by None | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.