Compiler error C2252/C2258 in VC6++ - and fix

Problems compiling? Don't understand the source code? Don't know how to code your feature? Post here.

Moderator: Moderators

hanberg
Posts: 1
Joined: 2003-02-15 12:37

Compiler error C2252/C2258 in VC6++ - and fix

Post by hanberg » 2003-09-29 19:40

As You might know by now v0.262 can't compile under vc6.

The compiler reports 292 errors refering to error C2252 and C2258
    --------------------Configuration: client - Win32 Debug--------------------
    Compiling...
    Util.cpp
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(52) : error C2258: illegal pure syntax, must be '= 0'
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(57) : see reference to class template instantiation 'PointerHash<T>' being compiled
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(52) : error C2252: 'bucket_size' : pure specifier can only be specified for functions
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(57) : see reference to class template instantiation 'PointerHash<T>' being compiled
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(53) : error C2258: illegal pure syntax, must be '= 0'
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(57) : see reference to class template instantiation 'PointerHash<T>' being compiled
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(53) : error C2252: 'min_buckets' : pure specifier can only be specified for functions
    g:\projects\dcplusplus-0.262-src-mod\client\util.h(57) : see reference to class template instantiation 'PointerHash<T>' being compiled
    Error executing cl.exe.

    Util.obj - 4 error(s), 0 warning(s)
The problem code is

Code: Select all

static const size_t bucket_size = 4;
static const size_t min_buckets = 8;

It's a bug in VC6++.

    The compiler does not support in-place initialization of static const integral member data as specified in the C++ standard (section 9.2) quoted in the following:

    4 - A member-declarator can contain a constant-initializer only if it declares a static member of integral or enumeration type.
At least the folowing code will let You build the exe file 8)

Code: Select all

#if _MSC_VER == 1200
   enum {bucket_size = 4};
   enum {min_buckets = 8};
#else
   static const size_t bucket_size = 4;
   static const size_t min_buckets = 8;
#endif // _MSC_VER == 1200

Hope it helps someone than me ...

GICodeWarior
Posts: 1
Joined: 2003-09-30 03:50

Post by GICodeWarior » 2003-09-30 04:04

Thank you!

Now I can compile...

~GICodeWarrior

Who is online

Users browsing this forum: Google [Bot] and 0 guests