Topic: Namespaces and main().


Author: ross@mks.com (Ross Ridge)
Date: Tue, 12 Jul 1994 10:02:47 GMT
Raw View
According r.3.4 of the C++RM main() is different from ordinary
functions in many ways:

 The function main() may not be called from within a
 program.  ... The address of main() cannot be taken
 and main() may not be declared inline or static.

Do these restrictions apply to function named main defined somewhere
else than the global namespace?  Can a function named main even be
defined somewhere else other than the global namespace?

      Ross Ridge





Author: schuenem@Informatik.TU-Muenchen.DE (Ulf Schuenemann)
Date: 15 Jul 1994 15:03:44 GMT
Raw View
In article <1994Jul12.100247.21734@mks.com>, ross@mks.com (Ross Ridge) writes:
|> According r.3.4 of the C++RM main() is different from ordinary
|> functions in many ways:
|>
|>  The function main() may not be called from within a
|>  program.  ... The address of main() cannot be taken
|>  and main() may not be declared inline or static.
|>
|> Do these restrictions apply to function named main defined somewhere
|> else than the global namespace? ...

I hope not.

|> ...  Can a function named main even be
|> defined somewhere else other than the global namespace?

I hope so.

|>       Ross Ridge
|>

The function called "main" that is actually 'the' main function
should always be the one (not overloadable) function "main"
that is declared in the global namespace. Any restrictions
should only apply to this special function.
If it were the other way, would ths restriction also apply
to static member-functions or to methods of a class? I hope not.

Sorry, that I don't _know_ the answer. This is just my opinion.


Ulf Schuenemann

--------------------------------------------------------------------
Ulf Sch   nemann
Institut f   r Informatik, Technische Universit   t M   nchen.
email: schuenem@informatik.tu-muenchen.de




Author: r-ridge@calum.csclub.uwaterloo.ca (Ross Ridge)
Date: Sun, 17 Jul 1994 02:58:36 GMT
Raw View
Ulf Schuenemann <schuenem@Informatik.TU-Muenchen.DE> wrote:
>The function called "main" that is actually 'the' main function
>should always be the one (not overloadable) function "main"
>that is declared in the global namespace. Any restrictions
>should only apply to this special function.
...
>Sorry, that I don't _know_ the answer. This is just my opinion.

Well, I not long after I posted my article I realized that their
not might be many people reading this newsgroup who would "know"
the answer.  Fortunately that was because the C++ standard
committee was meeting here in Waterloo this week, so took the
opportunity at hand I asked Andrew Koenig and Bjarne Stroustrup
in person.  They agreed with your answer.

      Ross Ridge

(Now, let's hope the compiler vendors agree too...)