On 22/09/05, Bill Wendling <isanbard at gmail.com> wrote:> Couldn't you state the explicit namespaces. So not using "using > namespace llvm" and instead prefix all calls with "llvm::"?The header files in boost do not use fully-qualified tie(). I probably should not modify them. But my .cpp file #include them. I hope I could "using namespace" boost and llvm in .cpp file, because it's tedious to use fully-qualified identifiers in boost and llvm namespace. -- Tzu-Chien Chiu, 3D Graphics Hardware Architect <URL:http://www.csie.nctu.edu.tw/~jwchiu>
On Thu, 22 Sep 2005, Tzu-Chien Chiu wrote:> On 22/09/05, Bill Wendling <isanbard at gmail.com> wrote: >> Couldn't you state the explicit namespaces. So not using "using >> namespace llvm" and instead prefix all calls with "llvm::"? > > The header files in boost do not use fully-qualified tie(). I probably > should not modify them. But my .cpp file #include them.That should be fine if they are in a namespace boost {}.> I hope I could "using namespace" boost and llvm in .cpp file, because > it's tedious to use fully-qualified identifiers in boost and llvm > namespace.Add: using boost::somethingyoucareabout; using boost::somethingelseyoucareabout; using namespace llvm; Or whatever you prefer. This way you only import the symbols you want. -Chris -- http://nondot.org/sabre/ http://llvm.org/
On Thursday 22 September 2005 19:12, Chris Lattner wrote:> On Thu, 22 Sep 2005, Tzu-Chien Chiu wrote: > > On 22/09/05, Bill Wendling <isanbard at gmail.com> wrote: > >> Couldn't you state the explicit namespaces. So not using "using > >> namespace llvm" and instead prefix all calls with "llvm::"? > > > > The header files in boost do not use fully-qualified tie(). I probably > > should not modify them. But my .cpp file #include them. > > That should be fine if they are in a namespace boost {}. > > > I hope I could "using namespace" boost and llvm in .cpp file, because > > it's tedious to use fully-qualified identifiers in boost and llvm > > namespace. > > Add: > > using boost::somethingyoucareabout; > using boost::somethingelseyoucareabout; > using namespace llvm; > > Or whatever you prefer. This way you only import the symbols you want.In fact, I believe that using namespace llvm; using namespace boost; using boost::tie; should resove the problem witout needed to explicitly nominate all boost names you use. Except that this does not work on global scope, but only in namespace: namespace Tzu_Chien_Chiu { using namespace llvm; using namespace boost; using boost::tie; void func() { // Use 'tie'. } } You can see "The C++ programming language", section C.10 for details. - Volodya
Sameer D. Sahasrabuddhe
2005-Sep-23 07:42 UTC
[LLVMdev] name collision - llvm::tie and boost::tie
Tzu-Chien Chiu wrote:> I hope I could "using namespace" boost and llvm in .cpp file, because > it's tedious to use fully-qualified identifiers in boost and llvm > namespace.How often do you need to mix the two libraries? Or specifically, use the two versions of tie() in the same cpp? A little #include discipline could go a long way in avoiding such clashes. LLVM source itself is a good example of how to avoid including headers unless absolutely necessary. Or, simply qualify tie() in the appropriate places, while you continue to use the "using namespace" directive. The following code works for me: #include <iostream> namespace one { void arbit_one() { std::cout << "arbit one" << std::endl; } void name_space() { std::cout << "namespace one" << std::endl; } } namespace two { void arbit_two() { std::cout << "arbit two" << std::endl; } void name_space() { std::cout << "namespace two" << std::endl; } } int main() { using namespace one; using namespace two; one::name_space(); arbit_one(); two::name_space(); arbit_two(); return 0; } Sameer. -- Research Scholar, KReSIT, IIT Bombay http://www.it.iitb.ac.in/~sameerds/
Reasonably Related Threads
- [LLVMdev] name collision - llvm::tie and boost::tie
- [LLVMdev] name collision - llvm::tie and boost::tie
- [LLVMdev] name collision - llvm::tie and boost::tie
- [LLVMdev] name collision - llvm::tie and boost::tie
- [LLVMdev] name collision - llvm::tie and boost::tie