Portability vs. Maintenance (ANSI vs. K&R C)

J.T. Conklin jtc at van-bc.UUCP
Wed May 30 03:49:27 AEST 1990


As systems vendors are beginning the slow transition towards ANSI
compliant compilers and libraries, applications developers such as
myself are left it a bit of a quandary: What is the most reasonable
approach to writing portable software?

  * The temptation is strong to ignore non-ANSI compilers entirely, as
    function prototypes and new-style declarations significantly increase
    productivity by reducing debugging time.  On the other hand, will the
    remaining vendors promises of an ANSI compiler "real soon now" be soon
    enough?

  * Another approach is to ignore ANSI compilers, and only use k&r syntax.
    This has the advantage of being universal, but the lack of compile-
    time type checking poses a serious disadvantage.  Lint is available,
    but will it be used?

  * Yet another approach is to do both, with the proper declaration
    selected with an #ifdef.  This works well, but there is a valid
    concern that both old- and new-style declarations will get out of
    sync during program maintenance.  How can you be assured that they
    never will.

  * A novel approach to the problem, would be to develop the code in
    ANSI C, but use a preprocessor of sorts to convert ANSI to k&r C
    before compilation.  Protoize/Unprotoize from the FSF works for
    prototypes, but some compilers even die on such benign stuff as
    #pragma's and #error's.  Furthermore, even unprotoize can't handle
    variable argument functions...

  * Lastly, one could carry port GCC to whatever platform you need to
    port your application to.  I have been doing this up till now, as
    GCC tends to be as least as reliable as the vendor's compiler.
    Of course, this isn't an option available to all.  Esp. if you
    aren't a compiler hack.


Still after all of this exploration, I am still unsure about which
path to follow.  Each has both its advantages and disadvantages.  I
hope the collective wisdom of the net can guide me in the right
direction.

Thank you

	--jtc


-- 
J.T. Conklin	UniFax Communications Inc.
		...!{uunet,ubc-cs}!van-bc!jtc, jtc at wimsey.bc.ca



More information about the Comp.lang.c mailing list