science@nems.dt.navy.mil (Mark Zimmermann) (06/04/90)
I am writing C using the newer ANSI-style function declarations (see examples below) and this is great for my Macintosh and PC C compilers -- but the generic UNIX 'cc' available to me on Macintosh under A/UX, on Sun Sparcstation, and on VAX under Ultrix do NOT understand this style, alas. Could somebody help me find or develop a quick program to convert from new ANSI-prototype-style declarators to the old way? I would estimate that this could be done in 5-10 lines of awk, since I can *guarantee* that my function declarations look like the following examples and never extend over more than 2 lines. But I'm not quite good enough at awk to do it myself, and I am sure that others must have encountered this same problem often enough to have solved it cleanly. My functions currently look like: main (int argc, char *argv[]) void print_help (void) void load_docfile (FILE* docfile, unsigned char *docp, long start, long doclength) void make_index_ptrs (unsigned char *doc0, long doclength, zndxptr *ptr0, long ptrcount) long write_index_files (unsigned char *doc0, zndxptr *ptr0, long ptrcount, FILE *kfile, FILE *pfile) ... and so forth ... in each case, the function declarator is followed by a newline, an indentation, and a '{' on a line by itself before the body of the function (in my typing style, anyway) ... apologies for not putting 'int' in front of 'main' ... Tnx for help!! ^z (science@nems.dt.navy.mil on Internet)
dankg@tornado.Berkeley.EDU (Dan KoGai) (06/06/90)
In article <2162@nems.dt.navy.mil> science@nems.dt.navy.mil (Mark Zimmermann) writes: >I am writing C using the newer ANSI-style function declarations (see >examples below) and this is great for my Macintosh and PC C compilers -- >but the generic UNIX 'cc' available to me on Macintosh under A/UX, on >Sun Sparcstation, and on VAX under Ultrix do NOT understand this style, >alas. Could somebody help me find or develop a quick program to convert >from new ANSI-prototype-style declarators to the old way? The easiest and most productive solution is get a copy of gcc--gcc is totally ANSI compliant and compiles old-style C as well. FSF is boycotting Apple so I'm not sure about A/UX (But there was emacs so it may be available) but for both Sparc and VAX, gcc is available. In my class assignments, we all use Ansi C thus gcc is the only compiler. None of my class account would compile on local cc. And gcc is better when compiling Xwindow application--it drove Apollo Domain's cc nuts--<X11/*.h> is usually written in Ansi style (or so my cpp said--maybe #ifdefs have some problems but that's rather old cc's fault). ---------------- ____ __ __ + Dan The "I love both GNU and Mac" Man ||__||__| + E-mail: dankg@ocf.berkeley.edu ____| ______ + Voice: +1 415-549-6111 | |__|__| + USnail: 1730 Laloma Berkeley, CA 94709 U.S.A |___ |__|__| + |____|____ + "What's the biggest U.S. export to Japan?" \_| | + "Bullshit. It makes the best fertilizer for their rice"