[Coco] ANSI -> K&R Code Conversion

KnudsenMJ at aol.com KnudsenMJ at aol.com
Fri Mar 18 12:35:28 EST 2005



In a message dated 3/17/05 8:42:26 PM Eastern Standard Time,
mannslists at invigorated.org writes:


>Would it be prudent to also look through some of the code and check for

things

>that would require another header under MWC? For example, the need to

include

>float.h (or whatever) when you try and print floats or doubles (along with

the

>added command pffinit ().) If I were to do this, I believe it would go

beyond

>what ANSI.C offers



This is a good idea.

The converter should also print warnings whenever a variable is declared
"unsigned char", since MWC does not support this, but will sign-extend any byte
between 128 and 255 into a negative integer. The user then has to insert the
(var & 255) expressions wherever 'var' is used as a Lvalue.

And keep in mind that pre-processing the ANSI prototypes out of the code,
loses the protections they offer against getting arguments the wrong type
(backwards, pointers to wrong length, etc.). Pointers to different lengths of
integers are especially important, since we'd be porting code from a 32-bit
integer world into a 16-bit, and probably changing the declarations of some of
the vars.

I am a late convert to ANSI C (we never used that newfangled NIH stuff at
Bell Labs, except maybe bitfields), but those prototypes and strict type
checking in the compiler *and* the linker have saved my cute little pair of
biscuits more than once. I hate core dumps (which you don't get in OS9, just a
freeze-up).
--Mike K.




More information about the Coco mailing list