This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Namespaces & main()


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 ?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]