🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5335

Re: C function prototyping and large projects

#5335
From: Frank Swarbrick
Date: Fri, 16 Sep 1988 23:51
66 lines
2705 bytes
In article <24@motto.UUCP> russ@motto.UUCP (Russell Crook) writes:
>We are just starting to use function prototypes, and are looking for
>suggestions on how to use them.
>
>We know that the Microsoft C compiler can automatically generate
>function prototypes.  Where do you go from there?  When developing
>a large program, composed of many source files, how do you 
>make sure each file picks up the right prototypes for the functions
>it uses?  Are there conventions about where prototypes are stored -
>do you put them in '.h' files, or right in the source file, or
>somewhere else?  Do you put all the prototypes for an entire program
>in one file, or do you use some means of only picking up the ones
>which are needed?  If you put them all in, does it affect compile
>time significantly?

Well, I've only been using C for a little over a year, so I've always
had a compiler that uses prototypes.  This is probably why it's so hard
for me to understand why people find them so hard to use.

ANYWAY...  I put all of the prototypes for non-static functions in a
separate header file and then include it.  For all the static (local to the
file) functions I write them in the file itself.  Here is an example.

-------------------------
/* myfile.h */
void lalaland(void);
void zzz(void);
-------------------
/* myfile.c */

#include "myfile.h"

static void foofoo(void);

void main()
{
   lalaland();
   zzz();
}

void lalaland()
{
   /* stuff */
}

void zzz()
{
   /* more stuff */
}

static void foofoo()
{
   /* local stuff */
}

>Do you regenerate the prototypes automatically, every time you rebuild
>or whenever the source file changes, or what?

I'm not quite sure what you mean.  The header files are compiled every
time they are #included, yes.  It may waste a few seconds, depending
on how large the header file(s) is(are).

Frank Swarbrick (and, yes, the net.cat)              | "1001001 -- S.O.S.
University of Colorado, Boulder                      |  1001001 -- in distress
swarbric@tramp.Colorado.EDU                          |  100100"
:...!{ncar|nbires}!boulder!tramp!swarbric            |                    -Rush 
Technical Details
Message-ID: <3511@boulder.Colorado.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ncar!boulder!tramp!swarbric
References: <24@motto.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ncar!boulder!tramp!swarbric
From: swarbric@tramp.Colorado.EDU (Frank Swarbrick)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: C function prototyping and large projects
Message-ID: <3511@boulder.Colorado.EDU>
Date: 16 Sep 88 23:51:51 GMT
References: <24@motto.UUCP>
Sender: news@boulder.Colorado.EDU
Reply-To: swarbric@tramp.Colorado.EDU (Frank Swarbrick)
Organization: Beautiful Boulder By The Bay
Lines: 66