www.digitalmars.com         C & C++   DMDScript  

c++ - bug: strange namespace bug

reply "Matthew Wilson" <matthew hat.stlsoft.dot.org> writes:
This has come up in the development of a new library - flecxx; zero-cost
flexibility for standard libraries - that I'm hoping to 0.1-launch this
month. DMC++ is the only compiler that has any kind of problems with what
I'm trying to do. Hopefully the bug is something very simple, and a fix can
be effected reasonably quickly.

The problem manifests even with one level of namespace
(dmc_ns_bug_small.cpp); I've submitted both because it's imperative for
flecxx that the two-level one (dmc_ns_bug.cpp) works.

Compilation of the "small" version gives:

P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(221)
: Error: namespace 'ns1' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(222)
: Error: undefined identifier 'ios_base'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(228)
: Error: namespace 'ns1' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(231)
: Error: namespace 'ns1' does not enclose member '?1' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(233)
: Error: namespace 'ns1' does not enclose member '?B_N' of namespace 'std
'
Fatal error: too many errors
--- errorlevel 1

Compilation of the two-level version gives:

P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(221)
: Error: namespace 'ns2' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(222)
: Error: undefined identifier 'ios_base'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(228)
: Error: namespace 'ns2' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(231)
: Error: namespace 'ns2' does not enclose member '?1' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(233)
: Error: namespace 'ns2' does not enclose member '?B_N' of namespace 'std
'
Fatal error: too many errors
--- errorlevel 1


Cheers

Matt


begin 666 dmc_ns_bug_small.zip
M4$L#!!0````(`' S93?;C%I=M ```$\!```4````9&UC7VYS7V)U9U]S;6%L
M;"YC<'!=4$T+PR ,O0O^A\ N&Q3*KJYXZ5_HO:1JF:!.JAV,TO^^VKJ/-KDD
M>2_O12DY:2?,*!54?8B#0LLIH<2A5<&C4.#"E9*)$E B*NL-1E6E^N558D&]
M89\H_K%FC_&M%09#  Z#%FTV_?$8^+$S6D"(DK$=J:H+:++&--_2G9#=I.J!
ML>76XXJXXU!L6JELXX ZAG7, 0-DWBHV0UG"X>4IGP\MP:)VY\OW*U:KO+S(
M)X&9DC=02P$"% `4````" !P,V4WVXQ:7;0```!/`0``% `````````!`" `
MMH$`````9&UC7VYS7V)U9U]S;6%L;"YC<'!02P4&``````$``0!"````Y ``
#````
`
end

begin 666 dmc_ns_bug.zip
M4$L#!!0````(`!0Q93<=CC79U0```-4!```.````9&UC7VYS7V)U9RYC<'!M
M4,$*PC ,O1?Z#P$O" .9QSI[V2]X'UE7L;#5L72"C/V[BZO,J3F4U^3EY252
M;)PW=5]9R"X4.HN-ED(*CXVE%HT%3ZD4PSIS>&5 BF";ML9 ,\:/UC(+\KGV
MCN2S=H83*$6A4LI<L2M"ARY0ENMU3_R:&HF 1'*FB/86GH*V+VMGWGHK6I8G
M<(XJT>O,5HO JF&[6PK#../QR+= Q/XK>YE&3?? Y_ ]C[=)_JW&6(,&B,R7
MY C[/7R=]">7,E.*^\U5T*#S;#'N\NDCZ (%UIZL/P%02P$"% `4````" `4
M,64W'8XUV=4```#5`0``# `````````!`" `MH$`````9&UC7VYS7V)U9RYC
8<'!02P4&``````$``0`\`````0$`````
`
end
Nov 04 2007
next sibling parent A. Fasten <fst911 gmail.com> writes:
I had a similar problem. The only solution I found, was to declare the class
that
used the std::* outside the namespace, then inherit or typedef it inside the
namespace, for example:

#include <fstream>

template< typename C, typename T >
class basic_fstream_outside : public ::std::basic_fstream<C, T>{};
namespace ns1
{
    template<   typename C
            ,   typename T
            >
    class basic_fstream
        : public ::basic_fstream_outside<C, T>
    {};

    typedef ::ns1::basic_fstream<char, ::std::char_traits<char> >  fstream;

} // namespace ns1


void main()
{
    ns1::fstream stm;
}
___________________________

I didn't test this out with fstream, rather the problem occurred with std::map.
std::string did not have this problem.
Dec 02 2007
prev sibling parent "Matthew Wilson" <matthew hat.stlsoft.dot.org> writes:
Any news on this? I'm about to launch flecxx in next week or so, and it'd be
nice not to have to #error on DMC++ for some of the components.

Cheers

Matt

"Matthew Wilson" <matthew hat.stlsoft.dot.org> wrote in message
news:fgl6jq$2mia$1 digitalmars.com...
 This has come up in the development of a new library - flecxx; zero-cost
 flexibility for standard libraries - that I'm hoping to 0.1-launch this
 month. DMC++ is the only compiler that has any kind of problems with what
 I'm trying to do. Hopefully the bug is something very simple, and a fix
can
 be effected reasonably quickly.

 The problem manifests even with one level of namespace
 (dmc_ns_bug_small.cpp); I've submitted both because it's imperative for
 flecxx that the two-level one (dmc_ns_bug.cpp) works.

 Compilation of the "small" version gives:
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(221)
 : Error: namespace 'ns1' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(222)
 : Error: undefined identifier 'ios_base'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(228)
 : Error: namespace 'ns1' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(231)
 : Error: namespace 'ns1' does not enclose member '?1' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(233)
 : Error: namespace 'ns1' does not enclose member '?B_N' of namespace 'std
 '
 Fatal error: too many errors
 --- errorlevel 1

 Compilation of the two-level version gives:
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(221)
 : Error: namespace 'ns2' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(222)
 : Error: undefined identifier 'ios_base'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(228)
 : Error: namespace 'ns2' does not enclose member '?0' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(231)
 : Error: namespace 'ns2' does not enclose member '?1' of namespace 'std'
P:\Programs\dm\Libraries\STL\STLport-4.5\stlport\stlport\stl/_istream.h(233)
 : Error: namespace 'ns2' does not enclose member '?B_N' of namespace 'std
 '
 Fatal error: too many errors
 --- errorlevel 1


 Cheers

 Matt
Dec 25 2007