[Development] Can we remove recommendation against unnamed namespaces from Qt coding conventions?
Giuseppe D'Angelo
giuseppe.dangelo at kdab.com
Wed Feb 21 18:26:48 CET 2024
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.dangelo at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4244 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20240221/edff91e5/attachment.bin>
More information about the Development
mailing list