views:

336

answers:

1

I am attempting to convert a c# to c++ with reflector. The code compiled, disassembled and reconstructed code is generating this error:

1>c:\users\user\documents\visual studio 2008\projects\reflect_readoo\reflect_readoo\readoo.cpp(2) : error C2059: syntax error : 'public'

1>c:\users\user\documents\visual studio 2008\projects\reflect_readoo\reflect_readoo\readoo.cpp(2) : error C2143: syntax error : missing ';' before '{'

1>c:\users\user\documents\visual studio 2008\projects\reflect_readoo\reflect_readoo\readoo.cpp(2) : error C2447: '{' : missing function header (old-style formal list?)

As I am unfamiliar with C++ syntax I'm not 100% sure where to start with these errors. The first the thing I tried was to remove all of the complicated code and just let the whole thing (it's one class in a namespace) be just a cout << "test"; in the namespace and class. removed the "ref" keyword, which removed the top error (this causes a million new errors wwith all of the functions in place) , but then was told a could only use a namespace if compiled with the clr flag, which would somewhat defeat the point of what i'm trying to do.

Can anyone recommend a path of testing that I could head down to start with? Otherwise, can anyone recommend a better way to translate a windows.form c# program into unmanaged c++? Should I just do it myself? (I want to do this eventually anyway, but it'd be a huge help to just have the damn thing and be able to look through and quickly see the differences, and I need the program for myself asap).

Thank you so much for any help, advice or guidance.

I understand the difficulty with the presentation side, I actually was not expecting for that to work, I just asked out of a dreamy hope. However, I would like to translate the "backend" of the application that was originally a console app. that I simply added as a class file to my windows form design. It's only this class of about a 1000 lines.

snippet:

        public ref class RProgram{

    public:
        static System::String ^KeywordsLog = "Keywords.log"; // WHERE THE PROGRAM KEEPS ITS LOG

// classes. . . functions. . . the errors are reported on the first lines


};

for that then I understand, and concede the impossibility I suppose then, but could someone be so kind as to please help me resolve the errors preventing its compilation as managed c++?

+4  A: 

You're going to have a very difficult time translating any reasonable complex Windows Forms application from C# to unmanaged C++.

You will not have access to any of the .NET framework libraries, which means no Windows Forms. You'll need to choose a different API for your windowing, such as MFC.

In general, this means that you'll need to completely rearchitect your applicaiton - at least the presentation side of it. My normal rule of thumb would be not to bother doing this - you have a working application, just keep it.

Reed Copsey
+1 Yep, looks like your tool is designed to convert to C++/CLI, not unmanaged C++.
Nick Meyer