[Qt-creator] unnamed namespace and internal linkage

Konstantin Tokarev annulen at yandex.ru
Tue Sep 22 15:37:55 CEST 2015



22.09.2015, 14:45, "Lorenz Haas" <lykurg at gmail.com>:
>>  I don't know, but shouldn't the "static" keyword be preferred anyway due
>>  to being less noisy?
>
> Okay, beside the theoretical question, let's make it concrete -and
> clear-: https://github.com/qtproject/qt-creator/blob/51bb52139c479cca2dae82eb08aeb8d04718fca1/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp#L52
> Should it be:
>
> a) namespace { const char kUseOtherFiles[] = "useOtherFiles"; }
> b) namespace { static const char kUseOtherFiles[] = "useOtherFiles"; }
> c) static const char kUseOtherFiles[] = "useOtherFiles";
>
> So one should favor c, right?
>

You should favor

d) const char kUseOtherFiles[] = "useOtherFiles";

because constants have internal linkage by default.


-- 
Regards,
Konstantin



More information about the Qt-creator mailing list