Path: utzoo!attcan!uunet!husc6!bbn!uwmcsd1!ig!agate!ucbvax!decwrl!purdue!i.cc.purdue.edu!j.cc.purdue.edu!pur-ee!uiucdcs!p.cs.uiuc.edu!dalenber From: dalenber@p.cs.uiuc.edu Newsgroups: comp.lang.c Subject: Function prototype generator Message-ID: <77200034@p.cs.uiuc.edu> Date: 23 Jun 88 23:34:00 GMT Lines: 75 Nf-ID: #N:p.cs.uiuc.edu:77200034:000:2500 Nf-From: p.cs.uiuc.edu!dalenber Jun 23 18:34:00 1988 For the past few weeks I have been writing a C-function prototype generator. I would say that it is now about 85% finished; it does just about everything I want it to do. The only area where it is really lacking is in handling array arguments to functions. For example, given the function definition: int func (arg) char arg[]; { /* ... */ } It will generate the prototype: extern int func (char arg[]); For this case, it is obvious that the argument in the prototype should be "char *arg", but what about multi-dimensional arrays? Should: int func (arg) int arg[][10]; { /* ... */ } produce: extern int func (char **arg); ? I seem to remember some notes about "pointer to array" being a legal type in "ANSI C"; how would definitions of this type differ from those above? Would it be legal to define a function returning a pointer to an array of int? And if so, how would such a thing be written? Should I just convert all array references to pointer references? If any ANSI-C gurus can answer these questions, I'll be eternally greatful (well, maybe not eternally :-) ). The second reason I am posting this note is ask the C community at large, "what features would you want in a prototype generator?" At present, the program accepts function definitions in either the old fashioned style used in the examples above, or the new ANSI style, formatted in any manner, and massages the information into prototype format. It produces output in the form #ifdef __STDC__#else #endif The token "__STDC__" can be set at run time to be any symbol. Also at run time, options can be given to exclude any static functions from the output, as well as the prototype for "main". What I'd like to know is, what else should it do? I'm particularly unsure how to handle multiple files. Should I generate one large output on standard-output, or into a user specified file; or should I automatically put the output for "file.c" into "file.p" (or something of that nature). A good user interface is very important, and I know that what I find natural may seem odd to others. Please send me your comments, and ideas. In a few weeks, after I've finished implementing everything, I'll post the source in comp.sources.{unix or misc} for all the world to enjoy. Much thanks in advance for any help I receive. Russel Dalenberg UUCP: {pur-ee,convex,ihnp4}!uiucdcs!dalenber ARPA: dalenber@p.cs.uiuc.edu CSNET: dalenber@UIUC.CSNET