简体   繁体   中英

How to migrate/convert a code of C++ ,built on Borland 2007 to Visual Studio 2010

Please guide me, as how to convert a C++ code of Borland 2007 in to Visual Studion 2010 code. I just need to ask, whether to write all th code again for 2010 or is there any shortcut for this conversion/migration.

i did and it worksd for me-

remove .h from include do not do it for other libraries,

remove clrscr(); everywhere and replace by system("cls");

finally after writing all #include stuff add this-

using namespace std; it allows you to do things like cin>> cout<< etc.

If the code was written portably to begin with, there should be no issues. Other than that, all I can say is to run the code through Visual Studio's compiler and see if you get errors or anything of that nature.

After that, test the output to ensure you're getting correct behavior.

Are you using any Borland proprietary components?

If so, I'd say you're out of luck. You'd have to replace those components, and this is likely not to be easy. I should say you may not find a tool that can automatically "translate" these.

If not, it should be easier. But be aware that Borland compiler has support for many things that are not C++ standard. If your code is portable enough, you'll be fine just recompiling it under VS. You might have to change some header files, replace some pragmas, but nothing too complicated.

If you're using the Borland GUI (TButton, etc) then you have some real work to do. Every one of them will need to be replaced with something Visual Studio knows - most probably MFC. About the time Visual C++ 4 was released I actually wrote a giant set of scripts (mostly using sed and awk) to convert a large codebase - it was not pleasant, the parameters are in different orders and the methods return slightly different types. It was worth it in that case - tens of thousands of lines of code and a strong business desire to switch tools. In your case since you say you have a "simple windows form with new controls" I would say start a new project, build the form, then copy your old code in - entire files for classes and business logic, clumps of lines for event handles in the gui. Test very carefully.

Also, the default MFC look and feel isn't the same as the Borland default look and feel. On that long ago project we had to look identical so we had to play with a lot of properties and options. Be sure to ask your bosss if this matters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM