Prototypes local or global opinions wanted

Patrick J Draper draper at buster.cps.msu.edu
Fri Jun 21 06:22:41 AEST 1991


I'm interested in what others think of the practice of declaring
function prototypes locally within a procedure.


local:

foo ()
{
 int bar (void);
 int x;

   x = bar ();

} 
--------------------------------------------------------------------

global:

int bar (void);

foo ()
{
 int x;

   x = bar ();
}


The advantage to the local declaration that I can see is that an
unintentional call to bar() will be flagged by the compiler. I prefer to
use the global declaration because if the definition of bar should
change, there's one place to change the prototype.

Any other opinions?

Thanks,
------------------------------------------------------------------------
Patrick Draper     "College is supposed to prepare you for the future,
cps.msu.edu               but all my future's behind me." 
draper at cps.msu.edu      -- My GrandPa, age 85, Fall 1990 graduate
                           of Western Michigan University 
------------------------------------------------------------------------



More information about the Comp.lang.c mailing list