Namespaces & main()

Gerald Gutierrez gutier@intergate.bc.ca
Sat Oct 10 18:34:00 GMT 1998


Hi all. I'm not very familiar with C++ namespaces yet so perhaps the
following may be correct behaviour. If so, please let me know.

If I try compiling the following :

namespace A { void main () { } }
namespace B { void main () { } }

egcs 1.1b gives me the following :

/tmp/ccNoTIxu.s: Assembler messages:
/tmp/ccNoTIxu.s:27: Fatal error: Symbol main already defined.

but if I renamed them to something else, like fmain(), then the code
compiles fine.

Alternatively, if I have the following :

namespace C {
    void main () { }
    namespace D {
        void main () { }
    }
}

I get :

/tmp/cc84q10E.s: Assembler messages:
/tmp/cc84q10E.s:27: Fatal error: Symbol main already defined.

as well. If I rename them to something else, the code compiles fine.

Is this correct C++ behaviour or is this something wrong with egcs ?



More information about the Gcc mailing list