www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/05/09:40:42

From: kagel AT quasar DOT bloomberg DOT com
Date: Wed, 5 Jun 1996 09:30:51 -0400
Message-Id: <9606051330.AA03942@quasar.bloomberg.com >
To: j DOT aldrich6 AT genie DOT com
Cc: djgpp AT delorie DOT com
In-Reply-To: <199606050616.AA022835366@relay1.geis.com> (j.aldrich6@genie.com)
Subject: Re: Beginners srand error
Reply-To: kagel AT dg1 DOT bloomberg DOT com

   From: j DOT aldrich6 AT genie DOT com
   Date: Wed,  5 Jun 96 06:26:00 UTC 0000

   Reply to message 3126053    from 95RGM AT ENG DOT CAM on 06/03/96  5:24PM

   >void main, anyone?

   As much as I'd like to, I've already said my piece on the subject.
   I could find the original posts and copy them, if you'd like?  ;)

   Well, maybe just once...

   void main() is BAD PROGRAMMING!  BAD!  Go sit in the corner for 30
   minutes!  :-P  The correct definition for main is:

   int main( void )

   if you don't need command-line arguments, or

   int main( int argc, char *argv[] )

   if you do.  Screw traditional C.

Just a note in my current campaign to make everyone aware of the issues in
writing portable code.  I like John's construct for declaring main, with
arguments best myself but, while DJGCC and all GNU compiler versions handle
this correctly, some commercial compilers for UNIX screw up, generating bad
code when an array is specified as the parameter to a function.  Declaring argv
as a pointer to pointer to char (char **argv) is safer for portable programs.
The DEC and MIPS compilers and at least one other I've worked with exhibit this
bug.  Passing in an array rather than an explicit pointer works OK, as does
declaring a function to accept a dimensioned array, but declaring a parameter
to be a dimension-less array causes confusion to some compilers.  FYI.

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

A proverb is no proverb to you 'till life has illustrated it.  -- John Keats

- Raw text -


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