[Coco] ANSI -> K&R Code Conversion
John R. Hogerhuis
jhoger at pobox.com
Wed Mar 16 21:33:40 EST 2005
On Wed, 2005-03-16 at 20:19 -0600, Mannequin* wrote:
> Okay, I'm prepared to begin to write or "update" a program that will convert
> program source from ANSI to K&R C.
>
Perl seems like a good language to do this kind of thing in. Good string
matching and processing. If you were really serious about it you would
hook your code into an existing C compiler lexer/parser.
> I have a question or two about it:
>
> First, what kind of interest is there in this kind of project?
>
I personally think effort would be better spent on sdcc for those that
have the time available.
> Will this aid us until there can be an ANSI C compatible compiler written for
> the Coco?
>
All this would provide is source code right? We already have a program
that does this.
Is it worth putting the extra work just to have source code for
something which will (hopefully soon) not be needed?
Also, dimes to donuts there is already something out there on the web
which does this.
> Last, but certainly not least, what are the major dividing points between the
> two styles? I'm the proud owner of both K&R 1 & 2, so I can look through the
> books, but I want everyone's opinion here, so I don't miss something rather
> important. :)
>
Off the top of my head:
Function definitions and declarations
Shortened typedef syntax in C99
C++ style comments (now part of C99, I believe...)
void * instead of char *
void return types
enum preferred to #define for sequential #'ing
Some things of course you can't remedy with this strategy, like lack of
bitfields in the Microware compiler.
Of course that says nothing about the serious issues like different
sizes of pointers and ints between architectures, but those problems are
inherent in any porting of most of the open source code on the web.
-- John.
More information about the Coco
mailing list