[edit]
I would have thought that even in C, one of the major points would be to rename structures and other datatypes, but yes, I agree with the principle.
Probably so, but it's not something I find myself doing quite as often. Also, I always name my structure tags with an _t suffix, so search-and-replace is reasonably simple when I rename them. [edit=2] Structure members are a different matter, of course. [/edit]
Consider also: local variables that overlap globals, so like CornedBee says, you have to track the scope.
Yes, and you also have to handle stuff like
Code:
int x;
{
int x;
{
int x;
}
}
so scoping would be essential. [/edit]
What you really need is a good name/scope tree that you can fill with input from multiple files.
Exactly! Any ideas?
Would it be that difficult to generate C code from a tree like that? Probably not . . . different styles would be another matter, but I'd leave that to indent.
Off the top of my head, I'd say simple renamings in C can't be too hard, provided that you're willing to accept errors introduced by weird preprocessor usage.
That's what I had thought.
Modularizing code (I think Fowler likes to call it "Method extraction") would be more useful, but certainly a lot more complicated. You'd have to look at what local variables a block of code uses, and if the code modifies more than one value, figure out how to return that to the calling function. With pointers, each variable would have to be modified.
On the other hand, it could be done only knowing the code for one function, because you're introducing new code, not modifying existing code.
Compared to C++, C is very easy to parse.
Yes, indeed.
If you need a preprocessor whose output you can actually use, consider Boost.Wave.
Boost.Wave does look interesting. I might consider it if I want to do preprocessing stuff -- though I usually use C instead of C++, for no particular reason. The Boost.Wave icon drives me nuts for some reason. It doesn't "move" often enough.