🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac.programmer.codewarrior
Article #22

Re: ANSI standards

#22
From: Ari Lukumies
Date: Mon, 18 Dec 1995 13:57
45 lines
1919 bytes
The ANSI standard states these formats for main:

  int	main(int argc, char **argv, char **env);
  int	main(int argc, char **argv);
  int	main(void);

Or you can use void as the return type. Some compilers make 
you explicitly state that you want ANSI compilation (eg, 
cc in HP-UX uses the flag -Aa), otherwise they don't recognize 
the ANSI prototypes, in which case you'd use

  int	main()
  int	main(argc, argv) int argc; char **argv; { ... }

or just plain

  main()

variants without the return type.

ANSI declares that there should be a compiler predefined 
identifier __STDC__ you can use for checking if the compiler 
is ANSI-compliant:

  #ifdef __STDC__
  ...
  #else
  ...
  #endif

Unfortunately, ANSI standard contains more than just the 
compiler, which has lead to many misuses considering the other 
parts of the compiling system, mainly the runtime libraries 
and header file names/functions. Many compiler vendors _do_ 
use the __STDC__ identifier but to only mark their _compiler_ 
as ANSI-compliant; they do not use it to tell that their 
libraries are also ANSI-compliant, and generally they are not. 
So I suggest you just go and test each and every 
compiler/platform and use some #define of your own to 
distinguish between them.

Ari Lukumies

-- 
All my opinions are mine and mine alone.
Technical Details
Message-ID: <30D57365.212D@cmt.lpr.mail.carel.fi>
Path: arc1-ca.pugleaf.net!news.lpr.carel.fi!usenet
References: <1995Dec14.120627.31590@ucl.ac.uk> <4b2me3$a8c@news.aloha.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.lpr.carel.fi!usenet
From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++
Subject: Re: ANSI standards
Date: Mon, 18 Dec 1995 15:57:57 +0200
Organization: Carelcomp Forest
Message-ID: <30D57365.212D@cmt.lpr.mail.carel.fi>
References: <1995Dec14.120627.31590@ucl.ac.uk> <4b2me3$a8c@news.aloha.com>
NNTP-Posting-Host: renoir.cclahti.carel.fi
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.0b2 (Windows; I; 32bit)