Boost logo

Boost :

From: Yitzhak Sapir (ysapir_at_[hidden])
Date: 2002-01-31 09:22:05

My experiment had a header which declared an int variable in an unnamed
namespace. Then it had two source files which use this variable in
functions (which sum this variable with their parameters), and the
main() in one source file called both functions. This produced a
problem when compiled with precompiled headers. When I changed the int
to static int (still in an unnamed namespace), it didn't have problems.
When run it seems to keep a different copy of the int for each source

-----Original Message-----
From: Fernando Cacciola [mailto:fcacciola_at_[hidden]]
Sent: Thursday, January 31, 2002 3:51 PM
To: boost_at_[hidden]
Subject: RE: [boost] boost bind/functional/reference wrapper/mem_fn

----- Original Message -----
From: Yitzhak Sapir <ysapir_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, January 31, 2002 9:46 AM
Subject: RE: [boost] boost bind/functional/reference wrapper/mem_fn

> MSVC getting confused about the precompiled headers with anonymous
> namespace is a bug in MSVC. Anonymous namespace should have been
> transparent with regards to precompiled headers. Therefore, if
> fixes it in MSVC, then that's all that is needed. Then you can #ifdef
> it in MSVC and non-MSVC wouldn't see the static. My test seems to
> that declaring it static fixes it. So I'd be happy with that.
> Does Borland have a problem with the non-static definitions in the
> anonymous namespace in precompiled headers?
Actually, it does...
It has problems with precompiled headers and unnamed namespaces
inside a named namespace).
You can look in the archives for a message with subject "boost::tuples
internal compiler error F1004"

I think that the problem with unnamed namespaces (the term used by the
is 'unnamed', not 'anonymous') is that it requires a hidden name unique
a translation unit. If you precompile a header which has an unnamed
namespace, when that header is loaded, precompiled as it is, in a second
translation unit, the compiler must 'fix' the hidden namespace name
it ought to be different in this second TU.

Whenever you experiment with precompiled headers, make sure to use also
second TU which uses it. In the case of the Borland bug, the csm is
generated OK, but the compiler ICEs (Internal Compiler Error) if it
tries to
use it.

BTW, in order to give an object internal linkage, you can use 'const' as
well, not only 'static'. In the case of the placeholders, I think they
be constant. However, this still produces initialized data which
headers to be precompiled in most compilers.

Fernando Cacciola
Sierra s.r.l.

Info: Send unsubscribe requests to:

Your use of Yahoo! Groups is subject to

Boost list run by bdawes at, gregod at, cpdaniel at, john at