www.digitalmars.com         C & C++   DMDScript  

c++.stl - STL & namespaces?

reply "Peter Dickinson" <petedgr8 yahoo.com> writes:
I am new to Digital Mars C++, and I'm trying it out with some code that
expects the STL to be in the std namespace (I'm trying the regression test
from the Boost libraries -  www.boost.org). I noticed in stl_config.h, that
the DM compiler does not define __STL_HAS_NAMESPACES, and when I try to use
it, I get various compilation errors. Is there something I need to do to
work with the STL in DM? Or is there a workaround for code that wants the
STL to be in the std namespace?

Thanks,

Pete Dickinson
Feb 05 2002
parent reply "Walter" <walter digitalmars.com> writes:
DMC++ supports namespaces as of the ARM, but not as of the latest STL. It
will eventually support it, but not yet. Sorry. -Walter

"Peter Dickinson" <petedgr8 yahoo.com> wrote in message
news:a3qa03$1tkk$1 digitaldaemon.com...
 I am new to Digital Mars C++, and I'm trying it out with some code that
 expects the STL to be in the std namespace (I'm trying the regression test
 from the Boost libraries -  www.boost.org). I noticed in stl_config.h,
that
 the DM compiler does not define __STL_HAS_NAMESPACES, and when I try to
use
 it, I get various compilation errors. Is there something I need to do to
 work with the STL in DM? Or is there a workaround for code that wants the
 STL to be in the std namespace?

 Thanks,

 Pete Dickinson
Feb 06 2002
parent reply Olivier Mascia <Olivier_member pathlink.com> writes:
In article <a3qqj5$250g$1 digitaldaemon.com>, Walter says...

 the DM compiler does not define __STL_HAS_NAMESPACES
DMC++ supports namespaces as of the ARM, but not as of the latest STL. It will eventually support it, but not yet. Sorry. -Walter
Taking into account the large number of programs using STL through std:: prefix a bit everywhere like in the following : #include <string> int main(int, char*[]) { std::string a; .. } doesn't this look like a very *serious* limitation ? Short of editing thousands of 'std::' prefixes how would you recommend porting existing code using STL to DMC ? Thanks for suggestions, -- Olivier Mascia
Jul 29 2003
next sibling parent reply "Walter" <walter digitalmars.com> writes:
"Olivier Mascia" <Olivier_member pathlink.com> wrote in message
news:bg6snj$2l81$1 digitaldaemon.com...
 In article <a3qqj5$250g$1 digitaldaemon.com>, Walter says...

 the DM compiler does not define __STL_HAS_NAMESPACES
DMC++ supports namespaces as of the ARM, but not as of the latest STL. It will eventually support it, but not yet. Sorry. -Walter
Taking into account the large number of programs using STL through std::
prefix
 a bit everywhere like in the following :

 #include <string>
 int main(int, char*[])
 {
 std::string a;
 ..
 }

 doesn't this look like a very *serious* limitation ?
 Short of editing thousands of 'std::' prefixes how would you recommend
porting
 existing code using STL to DMC ?
No problem, since DMC++ now supports namespaces. The message you replied to is about a year and a half old. -Walter
Jul 29 2003
parent reply Olivier Mascia <om-removethis tipgroup.com> writes:
Walter wrote:

#include <string>
int main(int, char*[])
{
std::string a;
..
}
No problem, since DMC++ now supports namespaces. The message you replied to is about a year and a half old. -Walter
Walter, I understood the message was *old*, but it was very actual to my findings. I cannot find the way to set the thing up to successfully compile a piece of code using STL which cross-compile successfully between GCC 3.2 (on linux, mingw and cygwin), Borland Builder 6, Microsoft Visual Studio. Without defining __STL_HAS_NAMESPACES I always end-up with 'string' not defined in std namespace. And with __STL_HAS_NAMESPACES I get other compile errors (the first one while including <vector>. Should I better use the stl provided with dmc or add STLport ? Or whatever ? I'm currently testing using the free downloadable compiler but will buy some CDs if I can get this to compile (and run). Thanks, -- Olivier Mascia
Jul 30 2003
next sibling parent Olivier Mascia <om-removethis tipgroup.com> writes:
Olivier Mascia wrote:

 Without defining __STL_HAS_NAMESPACES I always end-up with 'string' not 
 defined in std namespace.
 And with __STL_HAS_NAMESPACES I get other compile errors (the first one 
 while including <vector>.
More precisely, I see that in stl/stl_config.h the settings for DMC are still defined as this : www.digitalmars.com */ This does not properly place the STL things in std as should be done by default. Adding there or defining on command-line __STL_HAS_NAMESPACES introduces compilation bugs on some STL includes. -- Olivier Mascia
Jul 30 2003
prev sibling next sibling parent reply Olivier Mascia <om-removethis tipgroup.com> writes:
Olivier Mascia wrote:

 Without defining __STL_HAS_NAMESPACES I always end-up with 'string' not 
 defined in std namespace.
 And with __STL_HAS_NAMESPACES I get other compile errors (the first one 
 while including <vector>.
Walter, see the attached small test code demonstrating my issues. -- Olivier Mascia
Jul 30 2003
next sibling parent reply Olivier Mascia <om-removethis tipgroup.com> writes:
Olivier Mascia wrote:

 Walter, see the attached small test code demonstrating my issues.
I have now installed STLPort as available from digitalmars web site. I have much better results with it. My test code compiles. Though on the real project I want to compile, it fails with: Internal error: ph 1111 on the very first unit I compile. What is this error related with ? So that I can try to write a smaller test case to demonstrate it. Side question : on which group should I report things like an Internal error ? Thanks, -- Olivier Mascia
Jul 30 2003
next sibling parent Olivier Mascia <om-removethis tipgroup.com> writes:
Olivier Mascia wrote:

 I have now installed STLPort as available from digitalmars web site.
 I have much better results with it.
 My test code compiles.
 
 Though on the real project I want to compile, it fails with:
 
     Internal error: ph 1111
 
 on the very first unit I compile.
 What is this error related with ?
This error went away when I removed my -H and -HF flags. So it seems related to precompiled symbols handling. But I could work around it. -- Olivier Mascia
Jul 30 2003
prev sibling parent "Walter" <walter digitalmars.com> writes:
Reporting internal errors here is fine, or emailing them to me works fine
too. The most important thing is to provide a reproducible example.
Otherwise, they are essentially impractical to fix. -Walter

"Olivier Mascia" <om-removethis tipgroup.com> wrote in message
news:bg8fa5$18do$1 digitaldaemon.com...
 Olivier Mascia wrote:

 Walter, see the attached small test code demonstrating my issues.
I have now installed STLPort as available from digitalmars web site. I have much better results with it. My test code compiles. Though on the real project I want to compile, it fails with: Internal error: ph 1111 on the very first unit I compile. What is this error related with ? So that I can try to write a smaller test case to demonstrate it. Side question : on which group should I report things like an Internal error ? Thanks, -- Olivier Mascia
Jul 30 2003
prev sibling parent Olivier Mascia <om-removethis tipgroup.com> writes:
Yet another bug, this one produces a crash of the compiler.
There is a workaround though.
Walter, see the attached small test code demonstrating it.

-- 
Olivier Mascia
Jul 30 2003
prev sibling parent reply Olivier Mascia <om-removethis tipgroup.com> writes:
Olivier Mascia wrote:

 Should I better use the stl provided with dmc or add STLport ?
Answering to myself: trying to compile any *serious* code with the STL as provided in the stl directory of DMC 8.34 is a good way to loose time. :) Solution is to install the STLport version from the digitalmars.com website and correctly tune the bin/sc.ini file so that the stlport/stlport comes first (before other include directories). Also removing the other stl directory from this list of includes is not a bad idea. I could go as well as to remove the stl directory altogether ! :) Even with this there are still some quirks regarding apparently complex namespace handling. One of them can crash the compiler. See other posts. But can be worked-around. Having bombed this group with lots of questions and answers to myself over the last hours, I think a bit of explanation on what I was trying to achieve will be welcome. The piece of code which I was trying to compile with DMC is IBPP <http://www.ibpp.org>. This is a class library to access Firebird database server <http://www.firebirdsql.org> through its C-API much more easily than at the C level. Now with some work-arounds, the library does build correctly as well as its test programs, which run flawlessly. The next release of IBPP (2.2) will have DigitalMars Compiler listed as one of its supported compilers on Win32. -- Olivier Mascia
Jul 30 2003
parent "Walter" <walter digitalmars.com> writes:
"Olivier Mascia" <om-removethis tipgroup.com> wrote in message
news:bg8jp4$1ctr$1 digitaldaemon.com...
 Olivier Mascia wrote:

 Should I better use the stl provided with dmc or add STLport ?
Answering to myself: trying to compile any *serious* code with the STL as provided in the stl directory of DMC 8.34 is a good way to loose time.
:)
 Solution is to install the STLport version from the digitalmars.com
 website and correctly tune the bin/sc.ini file so that the
 stlport/stlport comes first (before other include directories). Also
 removing the other stl directory from this list of includes is not a bad
 idea. I could go as well as to remove the stl directory altogether ! :)

 Even with this there are still some quirks regarding apparently complex
 namespace handling. One of them can crash the compiler. See other posts.
 But can be worked-around.

 Having bombed this group with lots of questions and answers to myself
 over the last hours, I think a bit of explanation on what I was trying
 to achieve will be welcome.

 The piece of code which I was trying to compile with DMC is IBPP
 <http://www.ibpp.org>. This is a class library to access Firebird
 database server <http://www.firebirdsql.org> through its C-API much more
 easily than at the C level.

 Now with some work-arounds, the library does build correctly as well as
 its test programs, which run flawlessly. The next release of IBPP (2.2)
 will have DigitalMars Compiler listed as one of its supported compilers
 on Win32.
Great! Let me know when the release happens, with links to it, so I can list it as compatible with DMC++. -Walter
Jul 30 2003
prev sibling parent "Matthew Wilson" <matthew stlsoft.org> writes:
You can include the STLSoft root header stlsoft.h, and qualify with
stlsoft_ns_using_std() or stlsoft_ns_qual_std(), as in

#include <string>
int main(int, char*[])
{
    stlsoft_ns_qual_std(string) a;
    stlsoft_ns_qual_std(string) b;
    ..
}

or

#include <string>
int main(int, char*[])
{
    stlsoft_ns_using_std(string)

    string a;
    string b;
    ..
}

or

#include <string>
int main(int, char*[])
{
    typedef stlsoft_ns_qual_std(string)    string_t;

    string_t a;
    string_t b;
    ..
}



It's ugly (it's supposed to be!), but it is eminently portable between all
the STLSoft supported compilers (http://stlsoft.org/compilers.html)

"Olivier Mascia" <Olivier_member pathlink.com> wrote in message
news:bg6snj$2l81$1 digitaldaemon.com...
 In article <a3qqj5$250g$1 digitaldaemon.com>, Walter says...

 the DM compiler does not define __STL_HAS_NAMESPACES
DMC++ supports namespaces as of the ARM, but not as of the latest STL. It will eventually support it, but not yet. Sorry. -Walter
Taking into account the large number of programs using STL through std::
prefix
 a bit everywhere like in the following :

 #include <string>
 int main(int, char*[])
 {
 std::string a;
 ..
 }

 doesn't this look like a very *serious* limitation ?
 Short of editing thousands of 'std::' prefixes how would you recommend
porting
 existing code using STL to DMC ?

 Thanks for suggestions,
 -- 
 Olivier Mascia
Jul 29 2003