Summary of deANSIfiers.
Felix Lee
flee at shire.cs.psu.edu
Thu Mar 23 20:48:48 AEST 1989
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 <uunet!linus!
nixbur!nixpbe!nixbln!agc>, 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 <lupton at uhccux.uhcc.hawaii.edu>
sent me a short lex program that he will post to comp.sources.misc.
Lawrence C. Foard <lfoard at wpi.wpi.edu> 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 at shire.cs.psu.edu *!psuvax1!shire!flee
More information about the Comp.lang.c
mailing list