Posts Tagged ‘VC6’

How to get vc compiler version?

August 1, 2008 Leave a comment

Having trouble finding out your VC++ compiler version number? Let me help you out. 🙂 Open command prompt type and type in

cl.exe /?

Relevant part, as shown for me, is pasted here. My current compiler is VC6.

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80×86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Important pieces are in bold. Compiler is a 32-bit one and it’s version is 12.00.8804. So _MSC_VER will be 1200. Also the copyright year is important 1984-1998, this compiler was released in 1998, 1984 tells the year when Microsoft(R) Corp was registered as a company. 😉

So if you want to compile some piece of code just for VC6 compiler then you can add conditional compilation statements likewise…

#if _MSC_VER == 1200
  // Some VC6 specific code

For VC8, above copyright message looks like this for me…

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80×86 Copyright (C) Microsoft Corporation.  All rights reserved.

So _MSC_VER for VC8 will be 1400.

Now you may ask that how can I check full version of my vc++ compiler, for that purpose we have _MSC_FULL_VER macro defined.

#if _MSC_FULL_VER == 140050727
std::cout << "You are using vc8 compiler, version: " << _MSC_FULL_VER; #endif[/sourcecode] Values of _MSC_VER for different VC versions are listed below... VC6 - 1200 VC7 - 1300 VC8 - 1400 VC9 - 1500

How to convert iterator to corresponding data pointer?

July 25, 2008 5 comments

Well it was quite easy in VC6 to work with iterators since iterators were actual pointers to internal data, so they could be used interchangeably.

For e.g.

typedef std::vector<int> IntVector;
IntVector IntVecObj;

// Push in a thousand ints
for( int Index = 0; Index < 1000; ++Index )
   IntVecObj.push_back( Index + 1 );
// Access internal pointer
int *p = IntVecObj.begin();&#91;/sourcecode&#93;

But above code gives error if compiled in VC8! Says cannot convert from vector::iterator type to int*. Mmm, so how can we get the internal pointer? This is what I've done...

&#91;sourcecode language="cpp"&#93;// Following code snippet won't compile in VC6 hence the compilation guard
#if _MSC_VER >= 1400 // VC8 onwards
   int* p = &(*IntVecObj.begin());
   // Or // int* p = IntVecObj.begin()._Myptr;

You may ask why I had to take this approach? I am currently migrating a project from VC6 to VC8 hence plenty of code which directly uses pointers as iterators and iterators as pointers, so this helps. 🙂

I’ve got to say it’s a pain to work with new version of these stl classes, of course it could all turn out for good, sigh! anyway 😦

Categories: C++, VC++ Tags: , , ,

Build times in Visual Studio 6

Add /Y3 to msdev as command line, but you may say that this is not possible always when I click on visual studio icon.

Add a shortcut to msdev and in the “Target” edit box, to the end, add this option as /Y3. Now whenever you startup visual studio using this shortcut you should get build times.

Try this out with a test build. 🙂

Categories: Visual studio Tags: , , ,
%d bloggers like this: