Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-lcc!ames!haven!vrdxhq!bms-at!stuart From: stuart@bms-at.UUCP (Stuart Gathman) Newsgroups: comp.lang.c Subject: prototypes, old and new compilers Summary: A simple way to use prototypes on old and new compilers. Any better? Keywords: ansi K&R Message-ID: <136@bms-at.UUCP> Date: 14 Dec 88 22:02:26 GMT Organization: Business Management Systems, Inc., Fairfax, VA Lines: 42 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 <..!{vrdxhq|daitc}!bms-at!stuart>