Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!ncar!gatech!udel!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!jh4o+ From: jh4o+@andrew.cmu.edu (Jeffrey T. Hutzelman) Newsgroups: comp.sys.apple2 Subject: Re: Orca/C bug (void functions) Message-ID: Date: 9 Apr 91 02:25:33 GMT References: <1991Apr6.083344.26760@rbdc> Distribution: usa Organization: Carnegie Mellon, Pittsburgh, PA Lines: 48 In-Reply-To: <1991Apr6.083344.26760@rbdc> barry@rbdc (Barry Newberry) writes: > It appears that an old bug (feature?) has been left in Orca/C. Of course, > I never wrote Mike (W.) about it, because I thought someone else would > (my mistake). The compiler won't allow called functions to be type void. > The compiler blames the next line of code for the problem. From what I've > read, ANSI C allows functions to be type void, so I shouldn't have any > trouble with the following program. Changing type void functions to type > int takes care of the problems, but I like to use void for functions > which can't have errors or don't have to return values. > > /****************strange C program**************/ > void main (void) > { > thing (); > } > > void thing (void) > { > } This program IS erroneous. When you called thing() without a prior prototype, the compiler assumed it was type int. All C compilers I have ever seen do this. The proper code is below: /************* Corrected C Program *************/ void thing(); void main(void) { thing(); } void thing (void) { } /***********************************************/ That should compile correctly. > -- > ------------------------------------------------------------------------- > Remember, until there is a cure for Assembly Language Brain Fry, > there will always be the N.C. Home for Deranged Programmers. > ----------------------------------------------------------------------- -------------------- Jeffrey Hutzelman America Online: JeffreyH11 Internet: jh4o+@andrew.cmu.edu BITNET: JHUTZ@DRYCAS >> Apple // Forever!!! <<