I'm not trying to nest a namespace, I'm trying not to use a using directive in my header. I'm trying to alias a namespace 'name' with another name. In my header I have a global empty namespace with a full name. I want to assign another namespace to this name and then populate it with my source. I'm not sure what the appropriate syntax is for doing such a thing. Here is an example of what I have in my header file.
#ifndef SOME_HEADER_H
#define SOME_HEADER_H
namespace SomeLongNamespaceHere {} // Empty Global
namespace SLNH = SomeLongNamespaceHere; // Alias
namespace slnh = SLNH; // another lowercase alias
namespace slnh { // Compiler Error:
// My Declarations Here!
class foo{};
}
#endif // SOME_HEADER_H
1>------ Build started: Project: FileTester, Configuration: Debug Win32 ------
1> include.cpp
1>c:\users\skilz80\documents\visual studio 2015\projects\filetester\filetester\include.h(8): error C2757: 'mfbid': a symbol with this name already exists and therefore this name cannot be used as a namespace name
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I understand the compiler error and that is not the issue or the problem.
However when I do this:
namespace slnh{}
namespace slnh{
class foo{};
}
It compiles just fine. I'm not sure if I'm misunderstanding what a namespace alias exactly is and does or if I'm not using the proper syntax.
I am trying to use the shorter version in place of the longer version so that the user can just use the shorter version directly and when they hover over the shorter namespace it will automatically resolve back to the longer namespace and can be seen through features such as MSVS's intellisense or something similar. How can I achieve or mimic the behavior that I have described above?