我刚加入了一个新的C++软件项目,正在努力理解其设计。该项目经常使用未命名命名空间。例如,在类定义文件中可能会出现以下内容:
// newusertype.cc
namespace {
const int SIZE_OF_ARRAY_X;
const int SIZE_OF_ARRAY_Y;
bool getState(userType*,otherUserType*);
}
newusertype::newusertype(...) {...
在设计中有什么考虑因素会导致使用未命名的命名空间?有哪些优缺点?
static
的关系吗?能否请您与__attribute__ ((visibility ("hidden")))
进行比较? - phinz