Alex Rivera | Logout

Is it time to say goodbye to VC6 compiler?

Asked 2009-04-09T09:30:22.230
10

Of late I'm facing the issues that points finger to VC6 compiler.

Few of them are:

  1. A function-try-block doesn't work. Related Q
  2. in-class constant doesn't work.
  3. __FUNCTION_ (Macro to get function name) doesn't work
  4. The latest addition is it doesn't allow void functions to be passed as part of for_each.

The below example is not compiling with VC6 compiler. It says "error C2562: '()' : 'void' function returning a value". It looks like VC6 doesn't like void functions to be passed to for_each.

class Temp
{
public:
    Temp(int i):m_ii(i)
    {}

    int getI() const
    {
        return m_ii;
    }

    void printWithVoid()
    {
        cout<< "i = "<<m_ii<<endl;

    }
    bool printWithBool()
    {
        cout<< "i = "<<m_ii<<endl;
        return true;
    }
private:
    int m_ii;
};

int main(void) 
{
    std::vector<Temp>  arrTempObjects;

    arrTempObjects.push_back(Temp(0));
    arrTempObjects.push_back(Temp(2));

    //Doesnot work, compiler error 
    std::for_each(arrTempObjects.begin(), arrTempObjects.end(), std::mem_fun_ref(&Temp::printWithVoid));

    //Works
    std::for_each(arrTempObjects.begin(), arrTempObjects.end(), std::mem_fun_ref(&Temp::printWithBool));

    return 0;
}

Have you faced any other issues related to VC6.0. Any workaround to resolve these issues ? Or is it time to change the compiler?

Edit
Report

3 Answers

40

Quite frankly I can hardly understand why you wouldn't buy a modern computer and switch to Visual Studio 2008.

VC6 has got a deficient STL, poor C++ standard compliance and obsolete GUI.

You shouldn't let your competitors use better tools than you.

answered 2009-04-09T09:32:27.327
2

I changed from VC++ 6.0 to Code::Blocks (which is FOSS) with g++ a few months ago and haven't really looked back. I miss the VC++ debugger a bit, as the gdb implementation in CB is nowhere near as slick, but that's about all. Some things in the IDE work better (code completion, tooltips, dependancy xalculation) and the compiler is obviously much better.

Regarding your points, function try blocks are hardly a widely used feature, and most people think they are pretty useless. And the __FUNCTION__ macro is not part of the C++ Standard, so you shouldn't depend on it too much if portability is an issue.

answered 2009-04-09T09:41:14.980
2

No, it was time to say goodbye to it a decade ago. Here are a few reasons why:

  • There are free, standards-compliant compilers available, both from Microsoft and others
  • VC6 was written before the C++ language was standardized, and it is nowhere near standards compliant. Especially templates and the standard library live in a world of their own, with no tie to how these features actually work in ISO C++. The language it compiles is not C++. It is a hybrid of pre-standard C++, Microsoft extensions, compiler limitations and bugs. Neither of which are desirable.
  • VC6 is known to generate invalid code in some cases. Not only does it compile a home-made, buggy and nonstandard language, it also makes invalid optimizations causing crashes, or in some cases actually produces bad assembly that simply can not be executed.

It is broken, and it was always broken. It was designed to compile a language that ceased existing about the same time as the compiler was relased (when the language was standardized), and it failed even at that task, with countless bugs, some of which have been fixed in the half-dozen service packs that were released. But not all of them, and not even all the critical ones.

Of course, the downside to this is that your application is most likely just as broken. (not because you're bad programmers, but because it targets a broken compiler. It has to be broken to be accepted by VC6)

Porting that to a standards-compliant compiler is likely to be a lot of work. Don't assume that you can just import your old projects, click "build", and it'll work.

So if you're part of a big business that can't just take a month off to switch compilers, you might have to port it as a side project, while part of the team is maintaining the VC6 version. Don't scrap VC6 until you've successfully ported everything, and it works.

answered 2009-05-27T14:00:06.190

Your Answer