[webkit-dev] Build issues due to anonymous namespace

Darin Adler darin at apple.com
Sun Dec 3 13:47:01 PST 2017

> On Dec 3, 2017, at 12:16 PM, Filip Pizlo <fpizlo at apple.com> wrote:
> That also means not using static, for the same reason. FWIW, I think it’s a good idea.


There is definitely no benefit in wrapping a class, structure, or type definition in an anonymous namespace. My comment was specifically about a structure.

For functions and global variables, static or anonymous namespace does have one remaining benefit. It’s a way to communicate to the compiler’s warning system and the -Wmissing-declarations warning that the function does not need to have been previously declared in a header. So, for WebKit, these would not mean “I can rely on the fact that this name is private to this file”. They would mean “I only intend to use this in this file and so did not declare it in a header and so please don’t warn me about the fact that I did not”.

— Darin

More information about the webkit-dev mailing list