Xref: utzoo comp.lang.c:29331 comp.std.c:3187 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!ogicse!decwrl!shlump.nac.dec.com!mountn.dec.com!minow From: minow@mountn.dec.com (Martin Minow) Newsgroups: comp.lang.c,comp.std.c Subject: Re: Protoize/Unprotoize (was: ANSI C to K&R syntax converter) Summary: Why bother writing a tool? Message-ID: <1645@mountn.dec.com> Date: 4 Jun 90 18:57:05 GMT References: <1990May31.214655.18960@csrd.uiuc.edu> <26699454.10047@paris.ics.uci.edu> Reply-To: minow@thundr.enet.dec.com (Martin Minow) Followup-To: comp.lang.c Organization: Digital Equipment Corporation Lines: 44 In article <1990May31.214655.18960@csrd.uiuc.edu> pommerel@sp14.csrd.uiuc.edu (Claude Pommerell) writes: > >I am looking for a portable converter from ANSI C syntax to >traditional Kernighan&Ritchie syntax. I've had good results by writing prototypes using the following process: /* * prototype.h */ #ifdef _STDC_ #if _STDC_ != 0 #define _(x) x #endif #endif #ifndef _STDC_ #define _(x) () #endif /* * All functions are specified here: */ int sample _((int, char *, struct foo)); The actual definition of a function uses the old -- but still valid -- syntax: int sample(i, cp, foostruct) int i; char *cp; struct foo foostruct; ... The advantage is that your code remains maximally portable, yet you have the advantage of type-safety where available. The disadvantage is that you *must* not presuppose other Ansi features, such as automatic conversion of variables. Also, the above doesn't handle variable-length argument lists. (Also, strictly speaking, the macro '_' is reserved to the implementation). The above should be portable to all C implementations since around 1978. Martin Minow minow@thundr.enet.dec.com