473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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
3 1703
"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
"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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mart Rogers | last post by:
We have been trying to avoid switches to unmanaged code in our development, but have recently folded in a call to CDO by using System.Web.Mail as a quick way to send email. Yes this is a call to...
17
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
7
by: Patrick Kowalzick | last post by:
Dear all, I just wondered if it is possible to count the number of classes created via a template class at compile time. To show what I mean I post an example, which is not working but carries...
7
by: Tim Cowan | last post by:
Hi I was wondering if someone could help me change these ifs to a switch statement. I tried but I can't make it work. Thanks Tim Code below: protected void...
13
by: Adam Blair | last post by:
Is it possible to bind a switch statement to an Enum such that a compile-time error is raised if not all values within the Enum are handled in the switch statement? I realise you can use default:...
4
by: zlatko | last post by:
Hello. I am new to .net . I have a managed C++ library. It looks like this. // header file namespace cppnetdll { public __gc class Class1 { public: static int foo_int(void);
3
by: prakashwadhwani | last post by:
When my application starts 2 toolbars still remain open 1) Form View and 2) Formatting (Form/Report) Toolbar Also ... Access's default Menu-Bar also remains open. How to switch it off at...
3
by: Angus | last post by:
Hello I am getting this compile error: error C2259: 'PublicTON' : cannot instantiate abstract class due to following members: csta2less.h(1755) : see declaration of 'PublicTON' Class is like...
4
by: Duncan Smith | last post by:
I have a VS2005 C++ MFC project which #imports a type library. The goal is to introduce some managed code eventually, but for starters I just need to set the /clr compiler option and build the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.