[Qt-creator] unnamed namespace and internal linkage

Lorenz Haas lykurg at gmail.com
Tue Sep 22 13:12:50 CEST 2015


Hi,

our coding style states that

"Use static keywords instead of anonymous namespaces whenever
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
(ISO/IEC 14882, 7.1.1/6, or see various discussions about this on the
gcc mailing lists)."

After "hours" of studying the standard (C++11) I came to the
conclusion that this changed in C++11 and anonymous namespaces have
internal linkage:

ยง 5.5/4: "An unnamed namespace or a namespace declared directly or
indirectly within an unnamed namespace has internal linkage"

Can someone confirm that or reject. My C++ Standard knowledge is -
somehow - limited :) If it is true, we could alter our coding styles.

Thanks
Lorenz



More information about the Qt-creator mailing list