ANSI C -> non-ANSI C

Peter da Silva peter at ficc.ferranti.com
Mon Dec 3 01:08:37 AEST 1990


[ cross-posted to comp.std.c, because a tool like this would do more to speed
  the conversion of software to ANSI than all the debate in the world. Perhaps
  someone on the committee could do it in their copious spare time... :-> ]

> >Is there any software available to translate ANSI C to non-ANSI C?

> More seriously, you should be more specific about the problem
> that you think you're trying to solve.  Is it to eliminate
> parameters from prototypes in function declarations, or is it
> something more difficult?

I'd like some software to convert new- to old- style declarations myself.
None of the deproto tools I've seen so far do an adequate job, because
while they clean up the prototypes they don't clean up all the calls. For
example, if you want to run ANSI C through a K&R compiler, you need to change:

	int foo(char *, char *, int);
	char bazbuffer[BUFSIZ];

	foo(NULL, bazbuffer, 69);

Into:

	int foo();

	foo((char *)0, bazbuffer, 69);

Just removing the prototypes isn't enough. To do this right you pretty much
need a complete codewalker, so it might be cheaper just to go out and get a
new compiler. Unfortunately, sometimes one isn't available, and ignoring the
older systems is just going to ensure that islands of pre-ANSI C live forever
in dusty decks, waiting to catch the unwary.

Also, this hypothetical tool *would* just have to be written once. It doesn't
have any reason to do any machine-dependent stuff.
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.   'U`
peter at ferranti.com 



More information about the Comp.std.c mailing list