Re: MSVC C++ problems

From: Robert Collins <robertc@dont-contact.us>
Date: 14 Jul 2003 08:41:57 +1000

On Mon, 2003-07-14 at 03:08, Serassio Guido wrote:
> Hi Robert,
>
> Here are some interesting errors:
>
> ESI.cc
> c:\work\nt-3.0\include\array.h(64) : warning C4284: return type for
> 'VectorIteratorBase<class Vector<class HttpHdrRangeSpec *> >::operator ->'
> is 'class HttpHdrRangeSpec ** ' (ie; not a UDT or reference to a UDT. Will
> produce errors if applied using infix notation)

This is a warning, and it's a nonsense IMO. the method is defined as a
pointer to a UDT. If if causes you errors, we can think about how to
alter it.

> c:\work\nt-3.0\src\esicontext.h(75) : error C2248: 'Pointer' : cannot
> access private typedef declared in class 'ESIElement'
> c:\work\nt-3.0\src\esielement.h(68) : see declaration of 'Pointer'
> c:\work\nt-3.0\src\esicontext.h(143) : error C2248: 'Pointer' : cannot
> access private typedef declared in class 'ESIElement'
> c:\work\nt-3.0\src\esielement.h(68) : see declaration of 'Pointer'
>

try changing ESIElement from a struct to a class, and add public: at the
top:
struct ESIElement : public esiTreeParent
{
    typedef RefCount<ESIElement> Pointer;
->
class ESIElement : public esiTreeParent
{
public:
    typedef RefCount<ESIElement> Pointer;

> and many others like the last error.
>
>
> cbdata.cc
> C:\work\nt-3.0\src\cbdata.cc(114) : error C2258: illegal pure syntax, must
> be '= 0'
> C:\work\nt-3.0\src\cbdata.cc(114) : error C2252: 'Cookie' : pure specifier
> can only be specified for functions
> C:\work\nt-3.0\src\cbdata.cc(248) : error C2039: 'Cookie' : is not a member
> of 'cbdata'
> C:\work\nt-3.0\src\cbdata.cc(78) : see declaration of 'cbdata'
>
> There are other similar initialization errors in other sources, please can
> you give me a general guideline for the resolution.

Well, try this out, and we can generalise if it works:
===
    static const long Cookie = (long)0xDEADBEEF;
    static long MakeOffset();
    static const long Offset;
};
===
to
===
    static const long Cookie;
    static long MakeOffset();
    static const long Offset;
};

const long cbdata::Cookie((long)0xDEADBEEF);

===

>
> store.cc
> c:\work\nt-3.0\include\stack.h(54) : error C2059: syntax error : ''
> C:\work\nt-3.0\src\store.cc(1267) : see reference to function
> template instantiation 'void *__cdecl stackPop(class Vector<void *> *)'
> being compiled
> c:\work\nt-3.0\include\stack.h(56) : error C2059: syntax error : ''
> C:\work\nt-3.0\src\store.cc(1267) : see reference to function
> template instantiation 'void *__cdecl stackPop(class Vector<void *> *)'
> being compiled

it's probably MS having trouble with initialisers again.

The first line should instantiate as:
return (void *)();

as a test fix, try this - I haven't tested it..

in include/Array.h, change
typedef Vector<void *> Array;

to:
===
class SafeVoidPointer {
public:
  SafeVoidPointer() : _ptr(NULL) {}
  SafeVoidPointer(void *aPtr) : _ptr (aPtr) {}
  SafeVoidPointer(SafeVoidPointer const &old) : _ptr (old._ptr) {}
  SafeVoidPointer &operator=(SafeVoidPointer const &rhs) {
    _ptr = rhs._ptr;
  }
  // you may need some brackets in the next two lines
  // to tell MSVC the 'truth'.
  void * &operator *() const { return _ptr;}
  void * *operator -> () const {return &_ptr;}
private:
  void *_ptr;
};
typedef Vector<SafeVoidPointer> Array;
===

Cheers,
Rob

-- 
GPG key available at: <http://members.aardvark.net.au/lifeless/keys.txt>.

Received on Sun Jul 13 2003 - 16:42:08 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:20:16 MST