Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!news.funet.fi!hydra!cc.helsinki.fi!wirzenius From: wirzenius@cc.helsinki.fi (Lars Wirzenius) Newsgroups: comp.lang.c Subject: Re: External Functions Message-ID: <1991Mar16.125116.5560@cc.helsinki.fi> Date: 16 Mar 91 12:51:16 GMT References: <8146@rsiatl.Dixie.Com> Organization: University of Helsinki Lines: 20 In article <8146@rsiatl.Dixie.Com>, stan@Dixie.Com (Stan Brown) writes: [Edited for brevity --Lars Wirzenius] > Which of the folowing would be better & why (1) > extern void foo(); > void func1() { ... } > void func2() { ... } (2) > void func1() { extern void foo(); ... } > void func2() { extern void foo(); ... } (1) is better, since the declaration needs to be written only once, so there is less of a chance to introduce bugs when (not if) you change the function declaration. You could improve on (1) by putting its declaration (prototype if you have an ANSI compiler) into a header file, and #including that into any source file that calls foo, and also into the file that defines it (this is a handy way to ensure that declarations and definitions stay in sync). -- Lars Wirzenius wirzenius@cc.helsinki.fi