Re: What declarations of main exist in the c standard?



"Eric Sosman" <esosman@xxxxxxxxxxxxxxxxxxx> wrote in message
news:C-udnTvjjoEBYz_fRVn-qw@xxxxxxxxxxxxxx
> bjrnove wrote:
>> Hi.
>>
>> Me and a friend have a discussion about main. In my opinion the legal
>> ways of writing main is:
>>
>> int main(void);
>> int main(int,char**);
>>
>> My friend claims that you also have a standard version with enviroment
>> variables like this:
>> int main(int,char**,char**);
>>
>> Is that right or are my two versions the only standard c way to do it?
>
> The Standard guarantees that any hosted C implementation
> must accept your two forms. The Standard allows an implementation
> to accept other forms, too, but does not describe any of those
> implementation-specific alternative forms
<snip>

Actually, it does 'describe' one of those 'other forms'.

J.5.1 Environment arguments
[#1] In a hosted environment, the main function receives a
third argument, char *envp[], that points to a null-
terminated array of pointers to char, each of which points
to a string that provides information about the environment
for this execution of the program (5.1.2.2.1).


.



Relevant Pages

  • Re: command line
    ... The standard defines two environments, a freestanding environment ... it's helpful to think of a hosted environment as ...
    (comp.lang.c)
  • Re: command line
    ... The standard defines two environments, a freestanding environment ... it's helpful to think of a hosted environment as ...
    (comp.lang.c)
  • Re: ENV VAR addresses
    ... the best way to access an environment variable in a ... getenv() in my copy of the standard. ... it's possible your net portability gain ...
    (comp.lang.c)
  • Re: AMA wants stinkwheels?
    ... And it was the end of one of my worst days of flying ever. ... but the standard of behavior was not ... exactly the same tone I would people in here who call me a friend. ... I think RMD is flatlined. ...
    (rec.motorcycles.dirt)
  • Re: Wordset queries
    ... A cross-compiler is not a standard Forth system. ... of resources and can certainly afford to implement ENVIRONMENT?. ... All of the host system starts from source code, ... reference implementaton for X:extension-query for an example. ...
    (comp.lang.forth)

Loading