[webkit-dev] static const

Peter Kasting pkasting at google.com
Wed Sep 2 09:39:04 PDT 2009

On Wed, Sep 2, 2009 at 9:32 AM, Darin Adler <darin at apple.com> wrote:

> On Sep 2, 2009, at 9:31 AM, Alexey Proskuryakov wrote:
>  As an aside, is there any practical difference between "static const" and
>> "const" in C++? The only difference I'm aware of is that the former is
>> deprecated in the standard.
> I believe the former gives internal linkage and the latter external
> linkage, so I always use the former for things defined in a source file and
> not declared in a header file and the latter for things defined or declared
> in a header file.

This is correct (both about linking and about "static" being deprecated in
C++).  Note that Stroustrup's recommendation is to use an anonymous
namespace around source-file-local variables and functions rather than
declaring them static (due to its deprecation).  From my recollection this
is not precisely equivalent in meaning but it is nearly so.  I have seen and
used both in WebKit (although "static" is more common) and I believe the
Google style guide also allows both.

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

More information about the webkit-dev mailing list