From: David Abrahams (dave_at_[hidden])
Date: 2006-09-14 14:05:49
Gennaro Prota <gennaro_prota_at_[hidden]> writes:
> On Thu, 14 Sep 2006 07:00:26 -0400, David Abrahams
> <dave_at_[hidden]> wrote:
>>Gennaro Prota <gennaro_prota_at_[hidden]> writes:
>>> On Wed, 13 Sep 2006 22:00:09 +0200, Thorsten Ottosen
>>> <thorsten.ottosen_at_[hidden]> wrote:
>>>>What is the problem with an unnamed namespace in a header anyway? Is it
>>>>illegal according to the standard?
>>> Thorsten, this is not addressed to you, but I find shameful that so
>>> many boosters don't know this C++ 101.
>>Now, now, Genny. I don't recall anyone ever talking about the
>>problem until I raised it a year or two ago.
> And here's the ego I was talking about. You may feel like the first
> man who brought the light on all us,
Hey, now, back off. That's not ego, that's just my recollection.
> but that light is common advice for any comp.lang.c++.moderated
I thought of myself as a regular there, but I hadn't seen this
advice. That's the truth.
For what it's worth, I can find a mention of eschewing anonymous
namespaces in header files from Francis in Jan 2004, which is about 6
months before I started posting about it. However, that posting does
not mention the ODR and does little to clarify (for me) why it might
be a bad idea. Anyway, I don't need credit for discovering anything
here. My only point is that it's easy to be very involved in the
community and still never encounter the
unnamed-namespace-in-header/ODR issue. IMO, we ought to cut everyone
some slack and just keep working on education. There's no shame in
ignorance unless it's wilfull.
BTW, for anyone who still wants an explanation of the issues, I dug up
my original post:
> I guess I learned the facts from Francis Glassborow at least four
> years ago; and several modern books mention the problem: I'm sure
> about Sutter/Alexandrescu but there are others, I just don't have
> time to check.
FWIW, Sutter/Alexandrescu don't mention the ODR either; they just talk
about the amount of space generated in your program by repeated
definitions. If you were to read their advice you might think that in
general it's a bad idea to put objects with external linkage in a
header, but that what we're doing with the bind placeholders is OK.
> In any case I can't see any post in this thread which gives the
> correct explanation
I hope my link above works well enough in that department.
> (it seems that my newsreader have missed some message though
> --probably one between Arkadiy's and yours). And I really want to
> clarify that Thorsten attitude is absolutely ok: he is asking what
> the problem is. What's wrong is the attitude of those who think they
> know the reason without realizing they do not.
Now you've really lost me.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk