Topic: Strange compilation errors (MSVC)


Author: NO-SPAM.gareth@image.dk (Johan Bentzen)
Date: 1999/07/23
Raw View
On 21 Jul 99 01:50:37 GMT, Oleg Letsinsky <letsinsky@mtu-net.ru>
wrote:

>
>operator binstream& operator >> ( binstream& is, A*& obj )
>{
> //... something
>}
>

>Everything works fine with GCC (EGCS-1.1.2) under Linux and
>Windows, even with '-Wall -ansi' options... But Visual C++
>compiler (MSVC++ 6.0, SP3) complains about missing right-hand
>operator for 'A*'. Looks like it doesn't see operator for 'A*&' >:-0
>

This looks like a syntax hickup in MSVC.  I don't have MSVC available
right here to try it out, but have you tried a 'typedef A* Ap'?  It
might get over the problem MSVC seems to have with the '*&' sequence.

Johan

---------------------------------------------------
Johan Bentzen
7167  *  +45 21 83 92 72  *  +45 43 62 31 88
Glentehusene 73
2620  Albertslund
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Paul Baxter" <nospam@paje.globalnet.co.uk>
Date: 1999/07/23
Raw View
Don't think you should have spaces operator_ >>_ ( binstream in underlined
spots.

In general the streams >> and << are best used with text streams only aren't
they?

It probably IS a hiccup with MSVC, but the above points might help

Paul



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Oleg Letsinsky <letsinsky@mtu-net.ru>
Date: 1999/07/24
Raw View
NO-SPAM.gareth@image.dk (Johan Bentzen) writes:

> >Everything works fine with GCC (EGCS-1.1.2) under Linux and
> >Windows, even with '-Wall -ansi' options... But Visual C++
> >compiler (MSVC++ 6.0, SP3) complains about missing right-hand
> >operator for 'A*'. Looks like it doesn't see operator for 'A*&' >:-0
> >
>
> This looks like a syntax hickup in MSVC.  I don't have MSVC available
> right here to try it out, but have you tried a 'typedef A* Ap'?  It
> might get over the problem MSVC seems to have with the '*&' sequence.

No, everything is much simpler... and much more complicated at the
same time :-) I've already posted a follow-up to my message - I don't
know why it didn't appear in the NG - it wasn't an OT and I haven't used
nasty words... yet :-)

Let's consider the following situation:

namespace A {

template <class T>
some_function( stream& s, T& )
{
 s >> T; //---------(1)
}

}; // -- namespace A

//....something

using namespace A;

namespace B {

stream& s operator >> ( stream& s, Object*& obj ) //----(2)
{
 // do something
}

some_function<Object*> sf; //--------(3)

}; // -- namespace B;

Here code (3) instantiate template (1) which should use operator
(2). Now comes the funny part:

GCC sees the (2) and compiles the code without problems. Everything works.
MSVC complains in (3) that it can't find proper operator for (1).
<Sigh>...What's wrong?

Thanks,
 Oleg

--
This .sig is shareware ($10). Register now to get the full 10MB version!


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Oleg Letsinsky <letsinsky@mtu-net.ru>
Date: 1999/07/21
Raw View
Hi!

I have a rather trivial construction in my code. In a nutshell, this
is a framework for STL persistence support library I'm developing now.

class A {
 // some stuff
};

operator binstream& operator >> ( binstream& is, A*& obj )
{
 //... something
}

template<T>
binstream& operator >> ( binstream& is, std::vector<T>& vect )
{
 std::vector<T>::iterator itr = vect.begin();
 // some stuff here
 {
 is >> *itr; // <<<< - (the problem)
 }
 // ...and some stuff there
}

// some code below, in the main()
 std::vector<A*> objects;
 is >> objects;

Everything works fine with GCC (EGCS-1.1.2) under Linux and
Windows, even with '-Wall -ansi' options... But Visual C++
compiler (MSVC++ 6.0, SP3) complains about missing right-hand
operator for 'A*'. Looks like it doesn't see operator for 'A*&' >:-0

What's going on? Please help, this is an urgent work and this f**ng
error drives me crazy 8-[]

Please reply to the newsgroup - I'll be waiting for answer from both
work and home.

--
This .sig is shareware ($10). Register now to get the full 10MB version!
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]