"Eric M. Ludlam" <eric@...> writes:
> Iff your headers are anything like the the bits/stl_vector header I
> have, then it has a line in it like this:
>
> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
>
> which CEDET currently expands as:
>
> std::_GLIBCXX_STD_D
>
> If I declare a variable like this:
>
> std::_GLIBCXX_STD_D::vector<std::string> foo;
>
> I now get a big pile of possible completions.
>
> At this point, I need a C++/GLIBCXX expert from the mailing list to
> help me understand what the CEDET parse should be doing with these goofy
> constructs. I added some special code for these based on my
> understanding of the declarations, but in this case, something else
> seems to be expected.
>
> Any suggestions?
I'm surely no glibc expert, but maybe the following information
helps. Glibc has several specialized namespaces for 'std' (see [1]),
which can be activated through compiler flags. For example, if you
compile with '-D_GLIBCXX_PARALLEL' you activate the 'parallel mode',
which includes parallelized versions of STL algorithms (see [2]).
Now, all of this is done through something called 'namespace
association', using the '__attribute__ ((strong))' extension of gcc (see
[3]). This is all defined in c++config.h; for example, parallel mode
works as follows:
namespace std
{
namespace __norm { }
namespace __parallel { }
namespace __cxx1998 { }
using namespace __parallel __attribute__ ((strong));
using namespace __cxx1998 __attribute__ ((strong));
}
OK, so what should CEDET do... Well, I guess the easy way out is to just
pretend there is no namespace association. In this case, in c++config.h
it says
#ifndef _GLIBCXX_USE_NAMESPACE_ASSOCIATION
# define _GLIBCXX_STD_D _GLIBCXX_STD
# define _GLIBCXX_STD_P _GLIBCXX_STD
# define _GLIBCXX_STD std
# define _GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y) _GLIBCXX_BEGIN_NAMESPACE(X)
# define _GLIBCXX_END_NESTED_NAMESPACE _GLIBCXX_END_NAMESPACE
# define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY_ATTR(default) {
# define _GLIBCXX_END_NAMESPACE }
#else
As you can see, the second argument in the NESTED_NAMESPACE macro is
ignored. The visibility stuff, which I also struggled with in the Xapian
library, can be ignored, too. Maybe I'm mistaken, but it seems this all
effectively says 'namespace X' ?
Regards,
David
[1] http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.4/namespaces.html
[2] http://people.redhat.com/bkoz/parallel_mode/parallel_mode.html
[3] http://gcc.gnu.org/onlinedocs/gcc/Namespace-Association.html
|