Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #67412

Re: Can main() be called by itself?

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Can main() be called by itself?
Date 2015-08-14 11:14 -0700
Organization None to speak of
Message-ID <lnlhddagam.fsf@kst-u.example.com> (permalink)
References <39b9ef39-3874-4983-8165-035b51b78827@googlegroups.com> <mqjne6$o1$1@dont-email.me>

Show all headers | View raw


James Kuyper <jameskuyper@verizon.net> writes:
> On 08/13/2015 07:51 PM, fl wrote:
>> Recently, I had a quiz onsite. It looks like below, but it is not exactly (I
>> cannot remember its exact form now).
>> 
>> int main(int a)
>
> main() has two standard forms, and implementations are only required to
> accept it if defined with one of those two forms, or an equivalent. This
> isn't one of those forms.

main() may also be defined using some other implementation-defined form
(meaning the implementation must document it).  If an implementation's
documentation says that it accepts the above form, then it behaves in a
manner specified by the implementation.  If not, the behavior is
undefined.

In at least some implementations, though the behavior is not defined
either by the standard or by the implementation, will run normally, with
`a` initialized to the value that would have been stored in `argc`.

Defining it as:

    int main(int a, char **v)

would be valid (the names of the parameters are not mandated), and would
avoid several paragraphs of nitpicking.

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Can main() be called by itself? fl <rxjwg98@gmail.com> - 2015-08-13 16:51 -0700
  Re: Can main() be called by itself? Melzzzzz <mel@zzzzz.com> - 2015-08-14 01:58 +0200
  Re: Can main() be called by itself? James Kuyper <jameskuyper@verizon.net> - 2015-08-13 23:32 -0400
    Re: Can main() be called by itself? Keith Thompson <kst-u@mib.org> - 2015-08-14 11:14 -0700
  Re: Can main() be called by itself? Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-08-13 22:14 -0600
    Re: Can main() be called by itself? Keith Thompson <kst-u@mib.org> - 2015-08-14 11:15 -0700
  Re: Can main() be called by itself? gordonb.mj8yu@burditt.org (Gordon Burditt) - 2015-08-14 01:52 -0500
    Re: Can main() be called by itself? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-14 11:46 +0100
      Re: Can main() be called by itself? James Kuyper <jameskuyper@verizon.net> - 2015-08-14 07:54 -0400
        Re: Can main() be called by itself? Melzzzzz <mel@zzzzz.com> - 2015-08-14 14:19 +0200
          Re: Can main() be called by itself? David Brown <david.brown@hesbynett.no> - 2015-08-14 14:50 +0200
            Re: Can main() be called by itself? Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-16 10:39 -0700
      Re: Can main() be called by itself? gazelle@shell.xmission.com (Kenny McCormack) - 2015-08-14 12:32 +0000

csiph-web