Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!emory!hubcap!ncrcae!ncrlnk!ncrwic!wsuiar!mwjester From: mwjester@wsuiar.uucp (loki) Newsgroups: comp.lang.c Subject: Forward declaration (was Re: Novice question.) Message-ID: <427.2742a06f@wsuiar.uucp> Date: 15 Nov 90 19:04:31 GMT References: <336@brat.UUCP> <3838@vela.acs.oakland.edu> <1990Nov14.010511.7241@ux1.cso.uiuc.edu> <1990Nov14.143802.23021@noose.ecn.purdue.edu> Organization: Wichita State Univ., Wichita KS Lines: 37 In article <1990Nov14.143802.23021@noose.ecn.purdue.edu>, longshot@monkey.ecn.purdue.edu (The Knight Guard) writes: >> "extern" means that the variable is global, and was declared in a >>separate .c file. If your program occupies only 1 file, you will never >>use this. >> >>John Gordon > > Not true here... Our cc seems to require that all functions/procedures > be defined before the main block. The way around this is to extern all > functions before main... Dunno if this is just our compiler, anyone else > seen this? Any ideas of why? I'm not sure what compiler/environment you're using, but you will often find that a function used in main() is assumed to return type int unless the compiler has reason to believe otherwise. When the function appears later in the text and returns a different type, the compiler accuses you of redefining it. You should be able to work around this by defining the return type expected within main(), e.g. main() { int a,b; double bogus(); . . . } The above just lets the compiler know about bogus()'s return type, and you needn't specify the parameters to the function, just its type. Hope this helps. Max J.