[webkit-dev] Style guide should mention that we don't use anonymous namespace

Adam Barth abarth at webkit.org
Wed Oct 19 18:32:34 PDT 2011


On Wed, Oct 19, 2011 at 6:24 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
> Also... VC++'s debugger happens to have some issues around unnamed
> namespaces:
> http://msdn.microsoft.com/en-us/library/0888kc6a%28VS.80%29.aspx
>
> Don't recall if this affected classes inside unnamed namespace though.
> I think VC++ 2005's support for unnamed namespace is better than nested
> classes (cl.exe has some serious bugs in resolving nested class names) so if
> our only alternative to unnamed namespace is nested classes, then I'd much
> prefer unnamed namespace.
> Adam, do you recall any compiler/debugger issues with classes inside unnamed
> namespace on VC++ 2005?

Nope, but I haven't used VC 2005 in many years.

Adam


> On Wed, Oct 19, 2011 at 4:29 PM, Ryosuke Niwa <rniwa at webkit.org> wrote:
>>
>> On Wed, Oct 19, 2011 at 4:00 PM, Darin Adler <darin at apple.com> wrote:
>>>
>>> On Oct 19, 2011, at 3:58 PM, Ryosuke Niwa wrote:
>>> > On Wed, Oct 19, 2011 at 3:51 PM, Darin Adler <darin at apple.com> wrote:
>>> >>>  How about classes that are only used in one cpp file? Should we be
>>> >>> wrapping those in an anonymous namespace?
>>> >> I’d suggest not wrapping them in an anonymous namespace. Debugging
>>> >> tools work better when classes have unique names.
>>> >
>>> > Has this been a convention we use?
>>>
>>> I’m not sure how to answer that. I have not used anonymous namespaces in
>>> any WebKit code I contributed, and the first case of doing so that I recall
>>> was when Adam Barth used some in the HTML parser work.
>>
>> Okay. Sounds like it's left to reviewers' and committers' discretions.
>> It'll be still nice to give some guidance on when we should and should not
>> use anonymous namespaces so that I don't have to engage in a debate on every
>> code review.
>> I personally don't like anonymous namespaces because VS.net's class view
>> separates classes within anonymous namespace from the
>> rest: http://goo.gl/2IkzQ (screen shot)
>> But I think we've established that we prefer having unique class/function
>> names over using anonymous namespaces.
>> - Ryosuke
>
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>


More information about the webkit-dev mailing list