This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
STL in global or std namespace?
- To: <libstdc++ at sourceware dot cygnus dot com>
- Subject: STL in global or std namespace?
- From: "John Law" <john at geharris dot co dot uk>
- Date: Wed, 24 Nov 1999 15:14:37 -0000
Hi,
I'm currently using GCC 2.95.2 on my Linux box and have been getting
compilation
problems because one of my header file contains:
// header combined for c and c++
#ifdef __cplusplus
namespace Trans
{
#endif
typedef char unique[14];
#ifdef __cplusplus
}
using namespace Trans;
#endif
typedef struct
{
unique transaction_id;
} TEMPLATE;
I have found that whenever compiling a c++ application that includes this
header file I get "use of `unique' is ambiguous"
<path to header>/stl_algo.h:652: first declared as `_ForwardIter
unique(_ForwardIter, _ForwardIter, _BinaryPredicate)' here
/src/include/TransTemplate.h:42: also declared as `typedef char
Nmac::unique[14]' here
The surprising thing about this is that although it is considered bad
practice to
include the 'using namespace Trans' in a header file, this was I thought, a
simple
solution to a larger problem in that I didn't fancy having to rename each
unique
entry in all the source files that use 'unique' (which is over 750
files...). So
I simply include it within a namespace if compiling using c++. The errors
surprised
me in that I hadn't included 'using namespace std' so wasn't expecting to
get any
conflicts with STL's unique.
I suppose my question is if using libstdc++-2.90.6 is the STL included in
the global
namespace, or in the std namespace. It kind of looks like its still in the
global
namespace. If so, anyone got any ideas of when it will be in the std
namespace?
or anyone got any other simple soloutions to this problem?
Cheers
John