How to deal with predefined macro such as _MSC_VER when working with vc60 mode?

Mar 9, 2012 at 6:05 AM
Hi

I used to code using _MSC_VER macro to cope with both VC6 and higher version.
For example,

#if _MSC_VER == 1200
// In VC6, dwCount will have the size of the string data in bytes
dwCount /= sizeof(TCHAR); // count with terminating NULL included
=> effective count is dwCount - 1
#endif

If I use this code in vc60 settings, what value will _MSC_VER have?
If it is 1200, then it's ok, but if it is 0x0A00, then the above code
won't be included in compilation.

Please comment how to deal with this situation?
If possible, I want to keep the original code intact when working with
vc60 settings.


--
HaeRim Lee ()
InvestWare, Inc. (())
MultiCharts & TradeStation (2000i/8i) Services Provider

MP: +82-10-4035-2873
MSN: ehaerim@gmail.com
Nate: investra@nate.com
Skype:ehaerim
GTalk: ehaerim
Yahoo:ehaerim
Coordinator
Mar 9, 2012 at 6:05 PM

In VC 6,  _MSC_VER = 1200.

 

Mar 9, 2012 at 6:47 PM
Thx and I can see it is 1200 even though VC2010 IDE's IntelliSense
displays it as 1600 and make the code surrounded by "#if
_MSC_VER==1200" inactive.

This little inconvenience is unavoidable as long as working in vc60
settings, right?


rgds

HaeRim

On 3/10/12, owenwengerd <notifications@codeplex.com> wrote:
> From: owenwengerd
>
> In VC 6, _MSC_VER = 1200.
>
>


--
HaeRim Lee ()
InvestWare, Inc. (())
MultiCharts & TradeStation (2000i/8i) Services Provider

MP: +82-10-4035-2873
MSN: [email removed]
Nate: [email removed]
Skype:ehaerim
GTalk: ehaerim
Yahoo:ehaerim
Coordinator
Mar 9, 2012 at 10:25 PM

Offhand I don't see any solution short of defining _MSC_VER explicitly in your project settings. This would make a good bug report for Microsoft.

Mar 9, 2012 at 11:31 PM
Hi

I just added the following lines to my stdafx.h

#if defined(_MSC_VER)
#undef _MSC_VER
#define _MSC_VER 1200
#endif

With this, the IntelliSense now recognize the "#if _MSC_VER==1200 ...
#endif" block as "Active". It's good to see the IntelliSense working
ok now.

Then the next question arises.
Is it possible to know if the current project settings is in "vc60" mode?
For example, if Daffodil defined (implictily hopefully) the following
macros, I would use them appropriately.
- vc60, vc70, ..., vc100

Then I would rewrite the above #if block as follows:

#if defined(vc60)
#if defined(_MSC_VER)
#undef _MSC_VER
#define _MSC_VER 1200
#endif
#elif defined(vc80)
#if defined(_MSC_VER)
#undef _MSC_VER
#define _MSC_VER 1400
#endif
#endif

So is it possible to tell if the current Daffodil settings is vc60 or not?

many thx
HaeRim


On 3/10/12, owenwengerd <notifications@codeplex.com> wrote:
> From: owenwengerd
>
> Offhand I don't see any solution short of defining _MSC_VER explicitly in
> your project settings. This would make a good bug report for Microsoft.
>
>
Coordinator
Mar 10, 2012 at 4:08 AM

If you're going to set _MSC_VER in the same source file that tests its value, you defeat the purpose of using it. In that case you might as well remove the preprocessor conditions altogether.

There is no way using preprocessor symbols to discern the platform toolset except for values like _MSC_VER that are set by the build tool or your own symbols defined in your project settings.