On 21/02/2024 17:26, Jøger Hansegård via Development wrote:
Our Qt coding conventions (https://wiki.qt.io/Coding_Conventions <https://wiki.qt.io/Coding_Conventions>) has a statement on the use of unnamed (anonymous) namespaces. As far as I understand, this statement is now outdated. Can we delete this statement and lean on Cpp Core Guidelines Cpp Core Guidelines SF.22 instead https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-unnamed2 <https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-unnamed2>? Or do we need a Qt specific guideline on this topic?
I think the bullet point you want to remove is this one?
Avoid the use of anonymous namespaces in favor of the static keyword if possible. A name localized to the compilation unit with static is guaranteed to have internal linkage. For names declared in anonymous namespaces the C++ standard unfortunately mandates external linkage. (7.1.1/6, or see various discussions about this on the gcc mailing lists)
Indeed, this makes no sense written as-is. Just how old is this rule? Names in anonymous namespaces have internal linkage, at least since C++11:
https://timsong-cpp.github.io/cppwp/n3337/basic.link#4 I'd be in favour of suppressing it as well. My 2 c, -- Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - Trusted Software Excellence
smime.p7s
Description: S/MIME Cryptographic Signature
-- Development mailing list Development@qt-project.org https://lists.qt-project.org/listinfo/development