consider the following code:
struct foo {
typedef int bar;
};
namespace foo {
class baz {
/* code */
};
}
This is spread over a codebase that I have to work on, and it kind of works sometimes and I don't understand how.
As long as the namespace and the class don't occur in the same source (after preprocessing) it will work (I understand that part). However if suddenly both the namespace and the class are dragged into the same compilation unit by the preprocessor it (might) clash (I don't know if this ever occurs in the source).
Is there a convention that allows the compiler to always resolve code structures as those correctly? The most logical would be the forbid by namespaces and classes to have same symbols. The applied coding style allows clashing namespaces with classes albeit the ambiguity thus I would prefer a way to tell the compiler on usage instead of changing the coding convention.
something like:
use_namespace(foo)::baz b;
use_class(foo) b;