www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/02/10:29:04

From: kagel AT quasar DOT bloomberg DOT com
Date: Fri, 2 Aug 1996 10:06:18 -0400
Message-Id: <9608021406.AA05467@quasar.bloomberg.com >
To: j DOT aldrich6 AT genie DOT com
Cc: djgpp AT delorie DOT com
In-Reply-To: <199608012323.AA141401825@relay1.geis.com> (j.aldrich6@genie.com)
Subject: Re: Compile Errors
Reply-To: kagel AT dg1 DOT bloomberg DOT com

    >void Putpixel (int x, int y, unsigned char Col);
    >void Putpixel (int x, int y, unsigned char Col);      <---- why declared
    twice?
    >void TestPutpixel ();

    This is not the best or most ANSI way to declare these functions.
    They should look like this;

    void SetMCGA(void);
    void SetText(void);
    void Cls(unsigned char);
    void Putpixel(int, int, unsigned char);
    void TestPutpixel(void);

Hey don't beat the guy up on style S**T.  There is NOTHING wrong with his
declarations or his indentation style.  I personnally prefer his explicit
declarations with parameter names.  Indeed so did K&R in "The C Programming
Language, Second Edition" the use explicit prototype declarations for many code
samples and point out that the parameter names are optional in the "C"
standard.  I think that the parameter names enhance documentation value and, as
everyone on the list for any length of time knows I will pile my soap boxes
higher than Babel to promote better documented code.  


    >void TestPutpixel () {
    >    int loop1, loop2;
    >    for (loop1 = 0, loop1 < 319, loop1++) {
    >	    for (loop2 = 0, loop2 < 199, loop2++) {
    >	        putpixel (loop1, loop2, rand());
    >	    }
    >    }

    You need another closing brace here.  You really should line up opening
    and closing braces; the way you are doing it virtually guarantees lots
    and lots of annoying errors.


As far as LANDMARK's indentation style, hey that's been my style for over ten
years!  But seriously, it is the style promoted in all of the sample code in
K&R, do not pummel the newbie for emulating the greats!  (Meaning Brian and
Dennis not me.)  He is lining up his closing braces, with the matching opening
statement, HE JUST FORGOT ONE and as a newbie was just as likely to miss this
with any other indentation/brace position style!

    Argh!  Do I have to go through this again?!?  Please take whatever
    disk, manual, or person you got this program from and burn him/her/it
    at the stake.  There are only two *correct* ways to define main():

    int main( int argc, char **argv )
    Use this when you need command-line parameters.

    int main( void )
    Use this if you don't need command-line parameters.

Almost, actually there is a third valid definition for main():

	int main( int argc, char **argv, char **environment )

I hereby declare "Be Nice to Newbies Day", please!

-- 
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com

There is no future in any job.  The future lies in the man who holds the job.
-- George Crane

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019