Namespaces & main()

Branko Cibej branko.cibej@hermes.si
Wed Oct 14 06:09:00 GMT 1998


Alexandre Oliva wrote:

> Gerald Gutierrez <gutier@intergate.bc.ca> writes:
>
> > namespace A { void main () { } }
> > namespace B { void main () { } }
>
> > /tmp/ccNoTIxu.s: Assembler messages:
> > /tmp/ccNoTIxu.s:27: Fatal error: Symbol main already defined.
>
> > Is this correct C++ behaviour or is this something wrong with egcs ?
>
> It's a bug in egcs.  main() is only reserved in the global namespace,
> according to [basic.start.main]/3.  I've installed your testcase in
> the testsuite.

Just FYI, I tried the following:

     namespace A { int main() {} }

and got

     namespace-main.cc: In function `int main()':
     namespace-main.cc:2: warning: control reaches end of non-void function `main()'

while the following:

     int main() {}

Did not produce a warning. All of this seems OK to me.

--
Branko Cibej   <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49  fax: (++386 61) 186 52 70





More information about the Gcc mailing list