Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Rapture
USA (13 posts) bio
|
| Date |
Fri 03 Sep 2010 04:52 AM (UTC) [ quote
] |
| Message |
If one were brave enough to attempt a port from C to C++, what would be some of the obstacles in doing so?
I figure there are loads of benefits in attempting this, but I'm not overly familiar with the language. This would be a learning experience for me. | top |
|
| Posted by |
David Haley
USA (3,881 posts) bio
Moderator |
| Date |
Reply #1 on Fri 03 Sep 2010 05:06 AM (UTC) [ quote
] |
| Message |
The major issues you will run into...
- If you have constructors, you need to initialize the objects in question with 'new', not just malloc. Anything you create with 'new' must be destroyed with 'delete', not just free.
- g++ tends to be stricter than gcc; you will have to fix a lot of warnings like string constness.
If you don't have a clear idea of the benefits, then to be honest I wouldn't bother until you do. (There are benefits, it's just that you need to know how to take advantage of them to get them.) And when you do decide to convert, you really don't want to convert everything at once. You can convert in pieces, since C++ is (barring a few exceptions) basically a superset of C. (You'll have issues like 'class' no longer being an acceptable variable name.) So, convert pieces as you find ways to take advantage of C++. There is relatively little benefit in spending lots of time converting something if you only get gains in 5% of it; just convert the part you'll gain from. Many a coder has gotten burned out trying to convert everything in one fell swoop; it's easy to introduce bugs as you rearrange how memory is managed. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | top |
|
| Posted by |
Rapture
USA (13 posts) bio
|
| Date |
Reply #2 on Fri 03 Sep 2010 03:31 PM (UTC) [ quote
] |
| Message |
Thank you for the advice. Like I said, it's more of a learning experience than an optimization.
I'll look into it a bit more. | top |
|
| Posted by |
Samson
USA (683 posts) bio
|
| Date |
Reply #3 on Fri 03 Sep 2010 06:04 PM (UTC) [ quote
] |
| Message |
| Yes, take it from one who burned himself out on it. Don't go nuts and try to transform your entire codebase all at once :) |
SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center
"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984 | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,263 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )