prototypes, old and new compilers

Stuart Gathman stuart at bms-at.UUCP
Thu Dec 15 08:02:26 AEST 1988


To take advantage of prototypes but still remain compatible with older
compilers, we do the following:

    For ANSI compilers:

	int func(/**/ type, type /**/);

    For K&R compilers:

	int func(/* type, type */);

A convert program (e.g. sed) can easily turn '(/**/' into '(/*' and
vice versa.

This works well, but there are still some things on my wish list.

	1) many compilers take:

	      int func(/**/ type name1, type name2 /**/);

	   but we can't use this feature (to make header files more
	   self documenting) because of the ones that don't.

	2) Ansi requires '...' in a prototype to indicate varargs functions.  
	   Many compilers won't take '...' but use trailing comma instead.
	   
        3) The '/**/' is annoying when working with an ANSI compiler.

Does anyone have a parser that can recognize function prototypes and

	1) replace them with comments
		or
	2) strip the optional identifiers
		or
	3) add or remove the trailing '...'

By making some reasonable assumptions about coding style, it should work
without having to process typedefs or run the preprocessor.  I have started
such an animal, but don't have a lot of time to spend on it.  Has it been
done already?
-- 
Stuart D. Gathman	<stuart at bms-at.uucp>
			<..!{vrdxhq|daitc}!bms-at!stuart>



More information about the Comp.lang.c mailing list