🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1246

declaration of main

#1246
From: David Spuler
Date: Thu, 03 Sep 1992 00:36
25 lines
1382 bytes
A discussion of declaring main as returning void in comp.lang.c lead me
to read 5.1.2.2.1 "Program startup" in my ISO standard.  According to this
section, main can be declared as:

int main(void) { ... }
int main(int argc, char *argv[]) { ... }

Are the following also legal, although not explicitly mentioned?

int main()  { /* non-proto declaration */ }
main()  { /* non-proto declaration */ }
main(void) { /* implicit int */ ... }
int main(int argc, char **argv) { /* char **argv;  not char *argv[] ... }

Yes, I realize this sounds like a dumb question, but the standard doesn't
seem very precise. It implies that only the first 2 are legal.

Regards,
David Spuler
--
David Spuler, James Cook University of North Queensland, Australia
Author of "Comprehensive C", Prentice-Hall, 1992, pp416, ISBN  0-13-156514-1
INTRO TOPICS: types, operators, structures, strings, fns, ptrs, files etc etc
ADVANCED TOPICS: efficiency, debugging, style, portability, large programs
Technical Details
Message-ID: <spuler.715480577@coral.cs.jcu.edu.au>
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!marlin.jcu.edu.au!coral.cs.jcu.edu.au!spuler

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!marlin.jcu.edu.au!coral.cs.jcu.edu.au!spuler
From: spuler@coral.cs.jcu.edu.au (David Spuler)
Subject: declaration of main
Message-ID: <spuler.715480577@coral.cs.jcu.edu.au>
Sender: news@marlin.jcu.edu.au (USENET News System)
Organization: James Cook University
Date:  3 Sep 92 00:36:17 GMT
Lines: 25