conversion from 2003 to 2005 : revisited

P

Peter Oliphant

At one point I started a thread about how hard it is to convert 2003 Managed
C++ code to 2005 /clr C++ code, and said it was too hard. Well, now that
I've been doing it for a while, it isn't really that bad. You have to know a
few rules, and then just allow the compiler to tell you what's wrong.

I run the compiler, and then look at first error it reports. Correct, rinse,
lather, repeat. Usually errors can be corrected in one of the following
ways:

(*) change '*' to '^'
(*) change '__gc' to 'ref'
(*) remove __ from directives (e.g., __delegate => delegate)
(*) change new to gcnew

Arrays are the 'hard' one. change things of the form:

myClass my_class_array[] ;
my_class_array = new myClass[count];

to:

array<myClass>^ my_class_array ;
my_class_array = gcnew array<myClass>(count) ;

There are other changes, but these will get you through most conversions...
:)

[==P==]
 
T

Tom Serface

I think most people will kind of grow into the conversion (that's why they
put the switch to allow you to leave it the old way). Still, as you say,
when you really think about it the conversion is not rocket science. Thanks
for posting these steps. I think these may help others see that it's not
such a big leap to take even though initially they got like a gazillion
warning or error messages.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top