Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!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: <1991Mar17.224326.5579@cc.helsinki.fi> Date: 17 Mar 91 22:43:26 GMT References: <8146@rsiatl.Dixie.Com> <1991Mar16.125116.5560@cc.helsinki.fi> <8298@rsiatl.Dixie.Com> Organization: University of Helsinki Lines: 32 In article <8298@rsiatl.Dixie.Com>, stan@Dixie.Com (Stan Brown) writes: > If We put it in a .h file should we have one of these for eache > source file that contains calls to externaly defined functions? > Or should we put all the external functions into say exter,h > and imclude this everywhere. Obviously if we do this Personally I would split the project into modules, such that each module contains functions that 'belong together', e.g. one module contains only functions that do keyboard related stuff, another defines a (major) type and functions to manipulate that type. Each module has exactly one header file, which contains everything that the module 'exports', i.e. data types, function prototypes, #defines etc. Each module also has any suitable number of .c files that contain definitions of functions and other things don't belong to the header. If necessary, a module may contain 'private' headers, not to be included in other source files. > On the other hand if we have lots of include files we are back > to a maintenece headeache again. I think "my" method should be fairly good also from a maintenance point of view, since logically separated things are also separated in different source files, which makes it easy to change e.g. the implementation of a module, as long as the interface stays identical. It should also be easier to distribute the work if the modules stay separate, not to mention testing each module separately. However, I am by no means an expert on large projects (probably on nothing :-), so comments from more experienced people would probably be in order. -- Lars Wirzenius wirzenius@cc.helsinki.fi