Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!psuvax1!shire.cs.psu.edu!flee From: flee@shire.cs.psu.edu (Felix Lee) Newsgroups: comp.lang.c Subject: Summary of deANSIfiers. Message-ID: <4399@psuvax1.cs.psu.edu> Date: 23 Mar 89 10:48:48 GMT Sender: news@psuvax1.cs.psu.edu Reply-To: flee@shire.cs.psu.edu (Felix Lee) Organization: Penn State University Computer Science Lines: 60 I received several answers to my request for a program to undo ANSI function prototypes. The winner is "cfront", AT&T's C++ compiler, which generates pre-ANSI C code. This is a bit heavy if all you want is a deprototyper. If you're not going to be using C++'s features, you might as well get a native ANSI C compiler. "cfront" may be easier to port though. Honorable mention goes to AGCPP, by Alistair G. Crooks , posted to comp.os.minix 20 Feb 89. This tries to be an ANSI-conforming C preprocessor that also deANSIfies your program for your non-ANSI compiler. Pathological prototypes confuse it though. Smaller and simpler, Robert Lupton sent me a short lex program that he will post to comp.sources.misc. Lawrence C. Foard sent me a similar program written in C. Here is my pathological test file: ------------Start of pathological.c int getchar(void); /* 1a */ int printf(const char *, ...); /* 1b */ long atol(char *), strtol(char *, char **, int); /* 1c */ void (*signal(int, void (*)(int)))(int); /* 2a */ void (*signal(int sig, void (*f)(int)))(int) { } /* 2b */ double a (double b /* comment */, double o) { /* 3a */ extern char * iot(const char *); /* 3b */ { extern char * ity(int, int); } /* 3c */ } void var(const char * fmt, ...) { } /* 4 */ char *(d1), (*(d2))[], *((d3)[]); /* 5 */ struct t { int (*x)(y); }; /* 6 */ struct { int x, y; } xyz(struct { int x, y; } a) { } /* 7 */ int add(a, b) int a; int b; { } /* 8 */ ------------End of pathological.c GNU cc (1.34) digests the whole file happily. "cfront" (1.20) passes everything but: 2b. it misplaces the outer set of parentheses; 5. it claims a syntax error; 6. it claims a syntax error (replacing "y" with "int y" fixes this); 7. it doesn't support "struct {} xyz ()" (yet). The other deANSIfiers get less than half of the tests correct. None of the deANSIfiers will give you any warning that it has produced mangled output. -- Felix Lee flee@shire.cs.psu.edu *!psuvax1!shire!flee