www.digitalmars.com         C & C++   DMDScript  

c++.stlsoft - Ambiguous Symbol size_t

reply "Cláudio Albuquerque" <0318222801 netcabo.pt> writes:
Hi Mathew,

I'm using stlsoft 1.9.1-beta39 and Visual C++ 8.0 to do a simple thing.
So I did something like:


#include "stlsoft/conversion/explicit_cast.hpp"
namespace MyNamespace {
    using namespace stlsoft;
....
     void Func (void)
     {
     size_t s;
     ptrdiff_t x;
     .....
     }
And I get and error ambiguous symbol for 'size_t' : 'ptrdiff_t'.

Can you help me with this?

Thanks
Cláudio Albuquerque 
Jan 04 2007
parent reply "Matthew" <matthew hat.stlsoft.dot.org> writes:
Hi Claudio

Firstly, the problem has nothing to do with VC++ 8.

The problem here is that stlsoft defines size_t and ptrdiff_t in the stlsoft
namespace, and by introducing everything from STLSoft into MyNameSpace,
you're getting a conflict.

(The reason they're there is largely historical, for widest possible
compatibility with older compilers.)

The fix would be to either:
    - delete the using directive, and instead use using declarations, e.g.
using stlsoft::explicit_cast;
    - explicitly qualify the size_t and ptrdiff_t types when you use them,
e.g.

      void Func (void)
      {
      ::size_t s;
      ::ptrdiff_t x;
      .....
      }

The reason I've never run into the problem that you have is that I (almost)
*never* use using directives. However, other people do, and it's a part of
the language, so I think a remedy is in order.

Although it'll be a few days, I think I will address this before the next
(and possibly final) beta. Watch for an announcement post here.

HTH

Matthew

P.S. May I ask how you heard about STLSoft? :-)

"Cláudio Albuquerque" <0318222801 netcabo.pt> wrote in message
news:enjnqd$2qpj$1 digitaldaemon.com...
 Hi Mathew,

 I'm using stlsoft 1.9.1-beta39 and Visual C++ 8.0 to do a simple thing.
 So I did something like:


 #include "stlsoft/conversion/explicit_cast.hpp"
 namespace MyNamespace {
     using namespace stlsoft;
 ....
      void Func (void)
      {
      size_t s;
      ptrdiff_t x;
      .....
      }
 And I get and error ambiguous symbol for 'size_t' : 'ptrdiff_t'.

 Can you help me with this?

 Thanks
 Cláudio Albuquerque
Jan 04 2007
parent "Matthew" <matthew hat.stlsoft.dot.org> writes:
 Although it'll be a few days, I think I will address this before the next
 (and possibly final) beta. Watch for an announcement post here.
This has now been done. I need to run tests, and there're some other component fixes to be done, but this change'll definitely be in the next beta. Cheers Matthew
Jan 04 2007