Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to name the namespace of my new project?

Tags:

c++

namespaces

I'm going to create a new library that renders genome annotations into charts. However, as C++ doesn't have a centralized library website like Perl, how do I know if the namespace conflicts with any existing one?

like image 961
jiandingzhe Avatar asked Aug 04 '13 09:08

jiandingzhe


2 Answers

No, xd is not a good name: it's too short. It could be a good alias in a limited context, but for a library that will be used by others, provide a long, descriptive name. Then users can select an alias that makes sense for their project.

namespace my_company {
namespace XnoDraw {
// ...
} // namespace XnoDraw
} // namespace my_company

// user code, not your code:
namespace xd = my_company::XnoDraw;
like image 103
Pete Becker Avatar answered Oct 06 '22 00:10

Pete Becker


You could use anything except std.
Note that c++ doesn't allow compound names for namespaces.

For instance:

// Allowed
namespace a
{
    namespace b
    {
        int c;
    }
}

// Not allowed
namespace a::b
{
    int c;
}
like image 45
gifnoc-gkp Avatar answered Oct 06 '22 00:10

gifnoc-gkp