3 ms·
IMO module names should be the same as the namespace of objects exported by the module (more like Modula-2). I've never used C++20, but modules do seem a bit of
by HarHarVeryFunny 1y ago
IMO module names should be the same as the namespace of objects exported by the module (more like Modula-2). I've never used C++20, but modules do seem a bit of a mess.
Globally unique namespace names are needed to be able to differentiate the same name used in multiple namespaces, but of course are potentially a problem if you don't have control over them.
It might occasionally be useful if there was a workaround to resolve namespace clashes by doing something like:
namespace foo {
#include "foo/module.h" // namespace Module
using Module; // Module.x is now foo.x
}
namespace bar {
#include bar/module.h" // namespace Module
using Module; // Module.x is now bar.x
}
Or, we could invent a new syntax like "import foo/module as foo".
But AFAIK there is no way to then tell the linker to rename symbols to match (e.g. -l foo/module.o as foo -l bar/module.o as bar).
- 1718627440 1y ago> But AFAIK there is no way to then tell the linker to rename symbols to match (e.g. -l foo/module.o as foo -l bar/module.o as bar). Renaming symbols is done with objcopy. From objcopy(1): --redefine-sym old=new Change the name of a symbol old, to new. This can be useful when one is trying link two things together for which you have no source, and there are name collisions.