This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++: a bug or a feature ???
- From: Gokhan Kisacikoglu <kisa at centropolisfx dot com>
- To: Yzhar Keysar <yzhark at milk>
- Cc: gcc at gcc dot gnu dot org, gcc-help at gcc dot gnu dot org
- Date: Mon, 15 Jul 2002 10:54:02 -0700
- Subject: Re: g++: a bug or a feature ???
- Organization: Centropolis Effects, LLC
- References: <GZAXCL00.L3S@antares.silicon-value.com>
- Reply-to: kisa at centropolisfx dot com
This is the correct code:
-----------------------
//main.cc
#include <iostream>
#include "test.hh"
inline void g() { cerr<<"Main.g()\n" ; }
void main() {
g(); // wish to activate g() in main.cc
f(); // wish to activate g() in test.cc through f().
}
//--------end of main.cc
//test.cc
#include <iostream>
#include "test.hh"
namespace test_cc
{
inline void g() { cerr<<"Test.g()\n" ; }
}
void f() {
test_cc :: g(); // wish to activate g() in test.cc
}
---- OR ---------
using namespace test_cc; // in the scope of test.cc
void f() {
g(); // wish to activate g() in test.cc
}
//--------end of test.cc
// test.hh
void f();
//--------end of test.hh
The compiler has to make a decision on which g() to link with, obviously
the first one that is available is the one in main.
Gokhan