Re: Is this Standard C++: int main(int argC, char* argV[])?
From: tom_usenet (tom_usenet_at_hotmail.com)
Date: 06/10/04
- Next message: Brendan Grant: "Communications Breakdown with CSocket"
- Previous message: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- In reply to: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- Next in thread: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- Reply: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 10 Jun 2004 18:29:44 +0100
On Thu, 10 Jun 2004 13:09:29 -0400, "Steven T. Hatton"
<susudata@setidava.kushan.aa> wrote:
>Robert Bauck Hamar wrote:
>
>
>> Of course you have.
>> $ cat example.cc
>> #include <iostream>
>>
>> int main(int, char **, char *e[])
>> {
>> for (; *e; ++e)
>> std::cout << *e << std::endl;
>> }
>> $ g++ -ansi -Wall example.cc
>> $
>
>Interesting bit of hackery.
>
>> As you can see. This compiles without a warning on my compiler, and this
>> little program will print out my environment variables. A conforming
>> compiler is not required to compile this, but it is explicitly allowed
>> to.
>
>"Explicitly"? That seems a bit strong. How do you argue that it is explicit
>about this? The undefined catch-all?
No, the standard says that the type of main is implementation defined,
except that it must return int. It then goes on to say that int main()
and int main(int argc, char* argv[]) *must* be provided by all
implementations. So the above is just an implementation defined main
signature.
As for the naming of variables, I really don't think that the intent
of the standard is to ban naming the first and second parameter of
main whatever you want, but simply to give the required signatures of
main that should be available. The wording of the standard talks about
"allowing the following definitions of main". My understanding is that
it refers to the signatures, not the literal characters shown. So I
think that
int main(int const bubbles, char** fun)
{
}
is fine (note that top-level const in parameter types is not part of
the function signature).
Tom
-- C++ FAQ: http://www.parashift.com/c++-faq-lite/ C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
- Next message: Brendan Grant: "Communications Breakdown with CSocket"
- Previous message: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- In reply to: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- Next in thread: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- Reply: Steven T. Hatton: "Re: Is this Standard C++: int main(int argC, char* argV[])?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|