converting C# to C++

Red Squirrel

No Lifer
May 24, 2003
71,313
14,085
126
www.anyf.ca
I'm toying with the idea of converting a C# app to C++.

Lot of it would be manual, but some would be straight up conversions as the way the scripts are coded they have similarities.

What would be the best way to parse out such syntax then regenerate in a different way? I'm thinking perl would be a good language to learn in order to write conversion scripts. Any other good options? C++ is ok as well but wondering if there's something easier to use as far as parsing/generating goes. I know zero perl but I suppose it's fairly easy to pick it up.
 

Cogman

Lifer
Sep 19, 2000
10,286
147
106
I would think (but am not sure) that C# is close enough to c++ to allow almost a straight copy paste. Where you see differences, I doubt a parser could fix for you. (IE using the .Net library in any way) Those parts that don't just copy straight over will most likely have to be re-written by hand.
 

Red Squirrel

No Lifer
May 24, 2003
71,313
14,085
126
www.anyf.ca
well some stuff is different like how in C++ class prototypes should be seperated from source and what not, so I'll basically take the C# code, look at the functions, generate the prototype and then generate the proper files. I will also handle the special cases where .net specific stuff is to be converted to another format.

But come to think of it I might actually be able to run the entire thing through a parser of some sort, just need to decide how to go about writing this parser.
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
Come up with a plan early on for memory management... auto_ptr might be worth looking into.
 

Duwelon

Golden Member
Nov 3, 2004
1,058
0
0
Originally posted by: RedSquirrel
I'm toying with the idea of converting a C# app to C++.

Lot of it would be manual, but some would be straight up conversions as the way the scripts are coded they have similarities.

What would be the best way to parse out such syntax then regenerate in a different way? I'm thinking perl would be a good language to learn in order to write conversion scripts. Any other good options? C++ is ok as well but wondering if there's something easier to use as far as parsing/generating goes. I know zero perl but I suppose it's fairly easy to pick it up.

I'd go with Python over Perl as there are visual and OO similarities between Python and C++.