C declaration styles

Mark D. Freeman mdf at tut.cis.ohio-state.edu
Wed Mar 23 03:39:30 AEST 1988


In <1065 at sask.UUCP> coleman at sask.UUCP (Geoff Coleman @ College of Engineering) writes:
>> When I write my C functions on my personal computer, my declarations
>> are often like this :
>> 
>>           void foo(int x, double y)
>
>	Could you please tell us what kind of PC (if not an MS-DOS)
>and what kind of compiler you ate using. The above isn't Lattice
>or Microsoft and I would be suprised if it is Turbo.

Actually, Microsoft C 5.0 supports this syntax.  Soon, most C compilers
will, as it is part of the emerging ANSI C standard.  It allows the
compiler to do argument count and type checking, helping you to avoid
silly errors that are easy to miss when checking by hand.  

Another great idea:  make your declarations look like this...

void	foo(int x, double y)	/* DECLARATION */

and you can create quick and dirty documentation for yourself with one
grep piped through sort, resulting in an alphabetized list of all your
functions showing the number and types of arguments for each!  Great
for libraries that you are writing.

-- 
Mark D. Freeman						  (614) 262-1418
					      mdf at tut.cis.ohio-state.edu
2440 Medary Avenue	   ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!mdf
Columbus, OH  43202-3014      Guest account at The Ohio State University



More information about the Comp.lang.c mailing list