[webkit-dev] static const

Peter Kasting pkasting at google.com
Wed Sep 2 10:13:59 PDT 2009


On Wed, Sep 2, 2009 at 9:55 AM, Alexey Proskuryakov <ap at webkit.org> wrote:

> I don't have a normative reference at hand, but I'm fairly sure that both
> give internal linkage in C++ (unlike in C).
>
>
> http://stackoverflow.com/questions/998425/why-does-const-imply-internal-linkage-in-c-when-it-doesnt-in-c
> http://bytes.com/topic/c/answers/62013-const-has-internal-linkage-c


Interesting; I hadn't heard this before.

It has been a number of years since I read the relevant specs.  My
probably-faulty memory recalls things about most C compilers having a
concept of "common" linkage, where "int a;" defined in both foo.c and bar.c
would be accepted by the linker and turned into a single symbol.  Whether
this was the default varied, but apparently a lot of older C code depended
on it...

I had also thought that C++ aimed to have all file-scope objects (not just
const ones) have internal linkage unless declared "extern", but I had
thought that wasn't actually the case.

So apparently the only part I'm confident on is that Stroustrup deprecated
"static" for internal linkage and recommends anonymous namespaces in the
general case :)

PK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090902/86921506/attachment.html>


More information about the webkit-dev mailing list