hi all,
does anyone have an awk/sed/perl script to assist one with manual
rewriting from C++ to C?
(Class --> struct, method --> function, << >> to printf, etc...)
I have to rewrite a lot of legacy C++ code into a C-dialect of Plan 9
OS [sweetest Os around ;-) ]
http://plan9.bell-labs.com/plan9/
Why? Is the complexity of the C++ code too much for you and your team
to handle?
I've written some OO code in C before. It was a RT system, and I don't
think I need destructors on the auto 'object' variables (though there
/may/ have been some), since such code would have to be very carefully
constructed. C++ takes care of destruction of auto vars automatically,
making it somewhat easier in that regard.
A good chunk of the stuff I passed around were PODs[*], 98%-99% of them
constructed before runtime (static). Also, though I did careful cleanup
of all dynamically allocated 'objects', it wasn't all that critical
since once the system was running, nothing was deallocated. This is
because the operator would hit the off switch with no event propagated
to the computer. (Though if there was an event ever added, I
theoretically would have been able to recover all allocated memory and
done some additional cleanup on some resources.)
It was harder than C++ in some regards, easier in others. What was
harder was that I had to take in to account maintainability by others as
well, using plenty of wrapper functions, not requiring destructors being
called on stack allocated 'objects' (by making them PODs) and other
stuff. What was easier was that you knew _exactly_ what was going on.
Given everything that I just stated though, my question I put to you is
this: Do you *really* want to convert a C++ app that handled all the
destructors auto-magically, back to C? You might get more of a mess
than you started with when you start modifying the resulting code.
Just a thought.
Adrian
[*] Well everything in C is a POD, I actually mean that somewhat in the
spirit of C++. No destructor, (though I do allow for constructors
in a limited sense, where it doesn't allocate system resources),
etc...
--
_____________________________________________________________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under a Creative Commons /
\ Attribution-Share Alike 3.0 License /
\_______[
http://creativecommons.org/licenses/by-sa/3.0/]______/
\/_______[blog:_
http://adrians-musings.blogspot.com/]______\/