Visual Studio 6 and .NET not fully comptabible?

Started by
4 comments, last by GekkoCube 20 years ago
i ask this because whenever i take my work home (which has visual stuidio 6.0) i cant compile it without making any changes. for instance, on .NET i have a const static variable inside a class, and the whole program runs fine. but on 6.0 it complains about this.... here''s the error:

error C2258: illegal pure syntax, must be ''= 0''
and heres the snippet of code where it''s defined:

const static int m_itemMapIndex = 7;     
Advertisement
6 has some wierd quirks. the more standard way of writing that is:

static const int foo = 7;

static before const. try that and see if 6 likes it.

-me
nope.

it gives exact same error.
.NET is significantly more standards compliant than 6.0. However this is really more relevant in more substantial areas of a C++ compiler, such as templates. So .NET and 6.0 C++ are not 100% compatible. As far as the static const values I cannot say for certain.
i believe i solved it.

i had to do this in the header file:

const static int m_itemMapIndex;

...and then i had to define that again in the .cpp file, like this:

const int characterdlg::m_itemMapIndex = 7;

Funny, because i thought you could define static variables like that for basic datatypes. i guess this is a 6.0 feature.

thanks.
quote:Original post by GekkoCube
i guess this is a 6.0 feature.


That would be a 6.0 mis feature.

In any case, another method is just to redeclare your constant as an enum in the class. You might prefer that if you want to have the actual value show up inside the class definition proper.

This topic is closed to new replies.

Advertisement