By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,704 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,704 IT Pros & Developers. It's quick & easy.

Is there any compile switch that could turn all old C++ code into managed class?

P: n/a
If I have to add __gc in every class, it would be a huge work. Is there any
option that could compile all C++ class into manganged class without modify
any source code?
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Lei Jiang" <co**@263.net> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
If I have to add __gc in every class, it would be a huge work. Is there any option that could compile all C++ class into manganged class without modify any source code?


Just doing a Find/Replace for 'class' won't work - there's too many
differences in what you can do in managed/unmanaged classes that would make
that impossible. That's why you can compile managed and unmanaged C++ into
the same assembly - it means you don't need to convert everything all at
once but can do it as you have time. If you compile with the /CLR switch,
most stuff will get compiled into managed code, even though the classes
themselves aren't managed.

There may be refactoring tools out there tha can do this (or you could write
one) but I think it would be extremely hard to write such a tool.

Steve
Nov 17 '05 #2

P: n/a
"Lei Jiang" <co**@263.net> wrote in message news:<O4**************@TK2MSFTNGP12.phx.gbl>...
If I have to add __gc in every class, it would be a huge work. Is there any
option that could compile all C++ class into manganged class without modify
any source code?


Nope, sorry. life is not that simple ;-)

Further, I do not think that just by adding a __gc you can "convert"
your classes into managed classes. THere are many conceptual
differences that you just have to handle. For example, code that
instantiates any of your class objects on the stack will fail under
the managed version (you always create managed class instances on the
heap) and so on....

Two choices:

1. write a managed wrapper for each of your class
2. If you think adding a __gc will solve your problem (maybe you have
analysed the problem and figured that all you need is a __gc), in
which case, you can try adding a preprocessor definition like

#define class public __gc class

although I can bet a 100 bucks that #2 will just not work.

hth.
-Vinayak
Nov 17 '05 #3

P: n/a

Thanks. I understand that things are not that simple.

"Vinayak Raghuvamshi" <vs************@hotmail.com> ????
news:9a**************************@posting.google.c om...
"Lei Jiang" <co**@263.net> wrote in message

news:<O4**************@TK2MSFTNGP12.phx.gbl>...
If I have to add __gc in every class, it would be a huge work. Is there any option that could compile all C++ class into manganged class without modify any source code?


Nope, sorry. life is not that simple ;-)

Further, I do not think that just by adding a __gc you can "convert"
your classes into managed classes. THere are many conceptual
differences that you just have to handle. For example, code that
instantiates any of your class objects on the stack will fail under
the managed version (you always create managed class instances on the
heap) and so on....

Two choices:

1. write a managed wrapper for each of your class
2. If you think adding a __gc will solve your problem (maybe you have
analysed the problem and figured that all you need is a __gc), in
which case, you can try adding a preprocessor definition like

#define class public __gc class

although I can bet a 100 bucks that #2 will just not work.

hth.
-Vinayak

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.