Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2004

Tip: Looking for answers? Try searching our database.

Preprocessor definition not "inherited" when converting from VC++6

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paolo - 29 Jun 2004 09:20 GMT
I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInherit)" for each file.

For example: I had a DLL project in VC++6.0 where the definitions were:

_UNICODE,_DEBUG,_WIN32_DCOM,WIN32,_WINDOWS,_WINDLL,_AFXDLL,_USRDLL

In VC++7.1, these are the preprocessor definitions of the project (right-click the project in Solution Explorer and choose Properties -> C++ -> Preprocessor):
_DEBUG;_WIN32_DCOM;WIN32;_WINDOWS;_USRDLL
And the following are the preprocessor definitions of the .cpp files:
_UNICODE;_DEBUG;_WIN32_DCOM;WIN32;_WINDOWS;_WINDLL;_AFXDLL;_USRDLL;$(NoInherit)

Note that _UNICODE, _WINDLL and _AFXDLL have disappeared from the main project settings... I wonder why.

Is there a way to change this irritating behaviour? I'd like the source file to share settings as in VC++6.0.
If the only way is to fix it manually, shall I simply remove $(NoInherit) from each .cpp file, or add $(Inherit) ?

Furthermore, when I add a new source file to the project, its "preprocessor definition" text box is empty, and clicking on the "(...)" button I see (in the "preprocessor definition" dialog) that the checkbox "Inherit from project" is checked by default, and that the "inherited" preprocessor definitions are:

_DEBUG
_WIN32_DCOM
WIN32
_WINDOWS
_USRDLL
_WINDLL
_AFXDLL
_UNICODE
UNICODE

Note that this time we have _UNICODE, _WINDLL and _AFXDLL again, but we have also UNICODE without underscore (I read on a newsgroup that "The _UNICODE macro is used for the C run-time header files, and the UNICODE macro is used for the Win32 header files"). But where do these four phantom preprocessor definition come from?

If I compile the new .cpp file, I get a compiler warning (placed at the line where I include "StdAfx.h"):
warning C4005: 'UNICODE' : macro redefinition
d:\Programs\VisualStudio2003\Vc7\atlmfc\include\afxv_w32.h(123) : see previous definition of 'UNICODE'

The "previous definition" refers to the following lines of "afxv_w32.h"
#ifdef _UNICODE
#ifndef UNICODE
#define UNICODE         // UNICODE is used by Windows headers
#endif
#endif

Another post on a newsgroup says, "All you need to do is define _UNICODE.  The Microsoft headers automatically define UNICODE for you if _UNICODE has been defined."

But I didn't define UNICODE, it seems to appear from thin air... Can this "double definition" be a problem? How can avoid the warning?
Note that the "General -> Character Set" option has been set automatically to "Use Unicode Character Set".

Thank you very much
Paolo
Tarek Madkour [MSFT] - 29 Jun 2004 20:45 GMT
"=?Utf-8?B?UGFvbG8=?="
<toWriteMePrivatelyPleaseVisit@web.tiscali.it/fanelia/noi.html>
wrote in news:71ECF449-4FD0-4C73-94AC-82F6DB92B397@microsoft.com:

> For example: I had a DLL project in VC++6.0 where the
> definitions were:
[quoted text clipped - 12 lines]
> Note that _UNICODE, _WINDLL and _AFXDLL have disappeared from
> the main project settings... I wonder why.

_UNICODE, _WINDLL, and _AFXDLL are still defined in the main
project settings. Check the C/C++|Commandline node in the project
properties and you'll find them listed for the project.

In VS2002 (and up) these settings are imported using "property
sheets" (which is a level of property inheritance that we opened
up to users in VS2005) that specify these values as base values
for the project to inherit from. You control whether or not these
values are defined by changing the properties on the
"Configuration Properties | General" node. For example, setting
the configuration type to be a DLL will include the property sheet
that will define _WINDLL, etc.

Thanks,
Signature

Tarek Madkour, Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers
no rights.

Tarek Madkour [MSFT] - 29 Jun 2004 21:49 GMT
> _UNICODE, _WINDLL, and _AFXDLL are still defined in the main
> project settings. Check the C/C++|Commandline node in the
[quoted text clipped - 8 lines]
> the configuration type to be a DLL will include the property
> sheet that will define _WINDLL, etc.

More importantly... sticking all the preprocessor definitions on
the files with a $(NoInherit) is a bug in VS2003.

The right fix is to just remove all the per-file preprocessor
definitions (make it inherit from the project).

You can do this manually or you can write a macro and use the
object model. Alternativly, if you have access to VS2002 you could
upgrade the project using VS2002 and then upgrade it again from
VS2002 to VS2003. VS2002 did not have this bug and will
consequently do the correct upgrade.

Thanks,
Signature

Tarek Madkour, Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers
no rights.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.