473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Namespaces and shared libraries

I'm converting a library I've written so that all my code is in
namespace 'foo' (previously all my external symbols had a 'foo_'
prefix; I'm new to C++).

Question: my source files now have a 'using namespace foo' in them,
and I refer to all my library classes/methods/etc without a 'foo::'
qualifier. Is this a good idea? If I access my own ("private" to
myself) class 'bar' in the library, and I distribute the code as a
shared lib, will the loader get confused if it finds a user 'bar'?

Actually, the more I think about this, the more complex it gets.
Anyone know of a good reference for using namespaces with libraries?

Cheers

AL
Jul 23 '05 #1
1 1316
Andy Lomax wrote:
I'm converting a library I've written so that all my code is in
namespace 'foo' (previously all my external symbols had a 'foo_'
prefix; I'm new to C++).

Question: my source files now have a 'using namespace foo' in them,
and I refer to all my library classes/methods/etc without a 'foo::'
qualifier. Is this a good idea? If I access my own ("private" to
myself) class 'bar' in the library, and I distribute the code as a
shared lib, will the loader get confused if it finds a user 'bar'?

Actually, the more I think about this, the more complex it gets.
Anyone know of a good reference for using namespaces with libraries?


There's a recent addition to the FAQ that covers this issue quite
nicely. You can apply the same rules for your namespace foo as you can
for namespace std. See FAQ section 27.5.

Kristo

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Joshua Beall | last post by:
Hi All, I read in a forum somewhere that namespaces, though once supposed to be a part of PHP5, have been removed. Is this true? Can anyone show me the official statement by Zend that they...
24
by: Marcin Vorbrodt | last post by:
Here is an example of my code: //Header file #include <vector> using std::vector; namespace Revelation { // class definitions, etc... // class members are of type std::vector }
5
by: M Shafaat | last post by:
Hi, I want to develop a number of generic components which I intend to use in different applications. Is it a good idea to put all these generic components in one and the same namespace, e.g....
5
by: David T. Ashley | last post by:
I've occasionally had trouble compiling and linking programs that use shared libraries. That never made a lot of sense to me, because I thought the operating system went hunting for the symbols...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.