Path: utzoo!attcan!uunet!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.lang.c Subject: Re: prototypes, old and new compilers Keywords: ansi K&R Message-ID: <12816@steinmetz.ge.com> Date: 16 Dec 88 19:35:16 GMT References: <136@bms-at.UUCP> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: General Electric CRD, Schenectady, NY Lines: 54 In article <136@bms-at.UUCP> stuart@bms-at.UUCP (Stuart Gathman) writes: | 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 '...' I will share with you a little technique I use for allowing procedure declarations to hold what I want without having to rewrite the source code. Be warned, this addresses (1) and (2), and most of (3), but it's really ugly. Also, some compilers which take prototypes with type info don't accept elipsis, while others do. The comment shows where I change this if need be. ________________________________________________________________ #define NoProto 1 #define TypesOnly 2 #define FullANSI 3 #ifndef P #define P NoProto #endif #if P == NoProto #define Param(x) () #endif #if P == TypesOnly #define Param(x) x #define Ptype(x, y) x #define Pelipsis /* is this one right for you? */ #endif #if P == FullANSI #define Param(x) x #define Ptype(x,y) x y #define Pelipsis ,... #endif int someproc Param((Ptype(int *,x),Ptype(long,ypos))); int myprintf Param((Ptype(char *, format) Pelipsis)); ________________________________________________________________ This will doubtless start a macro war, in which ten people will tell me there's a better way, and another ten will ignore the comment about variable arguments and tell me Pelipsis has the wrong value for TypesOnly. Oh well, I hope this actually helps someone. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me