15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Where is _MFC_VER #defined?

Mario Contestabile -- Mario_Contestabile.UOS__MTL@UOSMTL2.universal.com
Monday, August 26, 1996

Environment: MSVC 4.2, Windows NT 4.0, Straight Forward Console App

I know _MFC_VER is #defined to 0x0420 in , and I want
to conditionally compile sections of code which are 4.2 dependent.

For example:
 #if _MFC_VER == 0x0420
...
#endif

I can't just #include, because it #includes ,
and it checks if _WINDOWS_ is #defined. If so, it generates an error.
It is the first #include in my compilation unit, and there is only one
source file in the project, so the problem must lie elsewhere.

It seems "_MFC_VER" is #defined at the preprocessor level,
as is  "_WINDOWS_" apparantly.
This is easy to check. If I insert 
#define _MFC_VER  2
as the first line in my source file, I will receive a warning that it is 
defined twice.

I can't find where it is defined in the Build/Options, but the odd thing is that
it is certainly not #defined as being 0x0420!

mcontest@universal.com




Ellis Brover -- Brover@MS_internet.siemens.com.au
Wednesday, August 28, 1996

[Mini-digest: 3 responses]


I think you're confusing _MSC_VER with _MFC_VER.

The former (_MSC_VER) is defined automatically by the compiler:
you will not find it #define'd in any headers. If you want to have
code that is dependent on the Visual C++ 4.2 COMPILER, use
this symbol. It is defined to 1000 for VC++ 4.0, 1010 for 4.1,
and 1020 for 4.2 (probably - I don't have 4.2 yet).

The latter (_MFC_VER) is defined in afxver_.h as you said,
not by the compiler. If you want to have code that is dependent
on the MFC 4.2 library, use this symbol. Rather than including
afxver_.h, you should include . The _MFC_VER symbol
is defined in hex, e.g. 0x0420 for MFC 4.2.

Hope this helps,

Ellis Brover
E & L Consulting
ebrover@ozemail.com.au

 ----------
From:  owner-mfc-l[SMTP:owner-mfc-l@majordomo.netcom.com]
Sent:  Monday, 26 August 1996 11:19
To:  mfc-l
Subject:  Where is _MFC_VER #defined?

Environment: MSVC 4.2, Windows NT 4.0, Straight Forward Console App

I know _MFC_VER is #defined to 0x0420 in , and I want
to conditionally compile sections of code which are 4.2 dependent.

For example:
 #if _MFC_VER == 0x0420
...
#endif

I can't just #include, because it #includes ,
and it checks if _WINDOWS_ is #defined. If so, it generates an error.
It is the first #include in my compilation unit, and there is only one
source file in the project, so the problem must lie elsewhere.

It seems "_MFC_VER" is #defined at the preprocessor level,
as is  "_WINDOWS_" apparantly.
This is easy to check. If I insert
#define _MFC_VER  2
as the first line in my source file, I will receive a warning that it is
defined twice.

I can't find where it is defined in the Build/Options, but the odd thing   
is
that
it is certainly not #defined as being 0x0420!

mcontest@universal.com



-----From: Phil Daley 

We use :

# if ( _MSC_VER >= 1010 )

to include VC 4.1 and greater

You could use:

# if ( _MSC_VER == 1020 )

if all you want is 4.2


Phil Daley          Relay Technology
http://www.conknet.com/~p_daley


-----From: Mike Morel 

Yes, 4.2 has forced many of us to conditionally compile code, due to the
amount and type of changes.  In my case, it was all in the ODBC classes.  I
found the symbol _MSC_VER defined, and saw some documentation somewhere (but
now I forget where).  My code looks like:

#if _MSC_VER > 1010	// VC 4.2 or greater

1000 is 4.0, 1010 is 4.1 and 1020 is 4.2.  Don't ask me why.

Mike

Mike Morel
Mushroom Software
mmorel@mushroomsoft.com
http://www.mushroomsoft.com/mushroom
MFC For Yourself - The programming partner for Visual C++ Developers





| Вернуться в корень Архива |