Reputation: 21166
I want to create a new library and want to make sure I'm not reusing a namespace that is already used by another library. By namespace I mean primarily a c++ namespace, but acronym collisions like the one between gnu scientific library and the guideline support library should ideally also be avoided.
What is an reasonable way to determine if a namespace is already used (beyond googling for " c++")?
Edit:
To clarify: I know there is no way to be certain that my namespace name is unique and even less that it will stay unique. What I'm looking for are tips to minimize the chance of a collision with commonly used libraries and/or libraries that are the defacto standard in some environment (e.g. I don't know anything about mac/ios/android specific libraries).
And yes, I could use my_ridiculously_long_but_unique_namespace_name_xy5md4
but that is imho not very practical if you want to use it in header files.
Upvotes: 1
Views: 276
Reputation: 1
What is an efficient way to determine if a namespace is already used (beyond googling for " c++")?
There is none. To have one would require a central repository (and a central authority managing it!) of every C++ source code, and we are fortunate to not have any (it would be a nightmare, and would restrict our freedom).
In practice, be pragmatical. Find a good, not too short, and rarely used name for your C++ project and use it (or something related) for your C++ namespace. If you intend to code a free software library for Linux, check that your putative name is not the name of some existing package in your favorite Linux distribution (e.g. in Debian)
For example mikematrixinversion
would be better than mi
.
For example, if you put your project as free software on github, you could check that your initial project name is not (often) used, and use that github project name as a namespace.
(in practice, you are worrying too much. Your project is more likely to be ignored, than to collide with some other name)
In a comment you mention
Is there some way to easily search all libraries in the ubuntu repository?
No, AFAIK. However, you might build something above compiler plugins or extensions (à la GCC MELT); it would take you years of work. And people do install on their Ubuntu system some external libraries, so you need to search a lot more (than what Ubuntu contains), and I won't be surprised if Ubuntu or Debian are large enough to already have conflicting libraries.
Look however into the softwareheritage project. BTW, searching for name and other similarities or analogies (using static source code analysis) in an entire Linux distribution is a very interesting research project. Look also into OSSmeter and CrossMiner projects (both are European funded).
Professionally, I intend to submit something related to the future ICT18 H2020 European call (in April 2018). If you are in Europe and are interested, please contact me.
And yes, I could use
my_ridiculously_long_but_unique_namespace_name_xy5md4
but that is imho not very practical if you want to use it in header files.
It is practical (you need good autocompletion in your editor). And as commented by sp2danny, you can have namespace aliases and you could also have preprocessor macros.
Upvotes: 8