473,698 Members | 2,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I imported a VC++6.0 project into VC++7.1. The conversion operation makes a mess with Preprocessor Definitions, adding a "$(NoInheri t)" for each file.

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

_UNICODE,_DEBUG ,_WIN32_DCOM,WI N32,_WINDOWS,_W INDLL,_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_D COM;WIN32;_WIND OWS;_USRDLL
And the following are the preprocessor definitions of the .cpp files:
_UNICODE;_DEBUG ;_WIN32_DCOM;WI N32;_WINDOWS;_W INDLL;_AFXDLL;_ USRDLL;$(NoInhe rit)

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 "preprocess or definition" text box is empty, and clicking on the "(...)" button I see (in the "preprocess or 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\Vis ualStudio2003\V c7\atlmfc\inclu de\afxv_w32.h(1 23) : 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
Nov 17 '05 #1
2 6637
"=?Utf-8?B?UGFvbG8=?="
<to************ *************** @web.tiscali.it/fanelia/noi.html>
wrote in news:71******** *************** ***********@mic rosoft.com:
For example: I had a DLL project in VC++6.0 where the
definitions were:

_UNICODE,_DEBUG ,_WIN32_DCOM,WI N32,_WINDOWS,_W INDLL,_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_D COM;WIN32;_WIND OWS;_USRDLL And the following are
the preprocessor definitions of the .cpp files:
_UNICODE;_DEBUG ;_WIN32_DCOM;WI N32;_WINDOWS;_W INDLL;_AFXDLL;
_USRDLL;$(NoInh erit)

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
"Configurat ion Properties | General" node. For example, setting
the configuration type to be a DLL will include the property sheet
that will define _WINDLL, etc.

Thanks,
--
Tarek Madkour, Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers
no rights.
Nov 17 '05 #2
"Tarek Madkour [MSFT]" <ta****@online. microsoft.com> wrote in
news:Xn******** *************** ******@207.46.2 48.16:
_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
"Configurat ion Properties | General" node. For example, setting
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,
--
Tarek Madkour, Visual C++ Team
This posting is provided "AS IS" with no warranties, and confers
no rights.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3661
by: Christian Brechbühler | last post by:
The template std::valarray behaves pretty much like a mathematical vector. Arithmetic operators apply elementwise. Now I'd like to extend this to a user-defined type, e.g., complex. Multiplying a double by a complex number gives a complex number. Now I would like to multiply a valarray of doubles by a complex number and get a valarray of complex numbers. Of course, a C++ compiler won't jump to that conclusion; I need to define...
235
11698
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could stay with C and still be able to produce Java byte code for platform independent apps. Also, old programs (with some tweaking) could be re-compiled and ported to the JVM. We have been developing such a tool over the last 2 years and currently...
7
42568
by: Bennett Haselton | last post by:
Is there any way to find a string representing an object's class, which will work in Internet Explorer 6? "typeof" doesn't work -- it returns "object" for all objects: x = window.open('http://www.yahoo.com/'); alert(typeof x); And I found this page: http://www.mozilla.org/js/language/js20-2002-04/core/expressions.html
3
3158
by: Paul Michaud | last post by:
Consider the following: Class A { .... } Class B:A { ....
24
1825
by: Nak | last post by:
Hi there, I have some inherited forms that I wish to make "localizable", unfortunately none of the items I wish to be "localizable" are actually being "localized". For example, I have a few of properties which set the text of some labels on the form which are inherited from the base form, these text values aren't "localized" Has anyone any ideas where I'm going wrong? Nick.
5
1956
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base class"
12
2402
by: Steve Pope | last post by:
Compiling the following works on my system: file main.cpp: #include <iostream> namespace space { int foo; }
2
2229
by: Emmanuel Deloget | last post by:
Hello, I'm trying to find a (sfinae powered) way to verify if a particular type declares a subtype (either using typedef or by declaring a subclass). To be more concrete, let's say that I'm trying to see how to implement a tiny part of tr1::reference_wrapper, more exactly the definition of its weak result type. Let's imagine that class A and B inherit both std::unary_function and std::binary_function. As such, they also inherit
8
1795
by: Rasmus Kromann-Larsen | last post by:
The With Conundrum I'm currently writing a master thesis on (preparations for) static analysis of JavaScript, and after investigating the with statement, it only even more evident to me that the with statement is indeed bad. My initial thoughts on with were based on: http://yuiblog.com/blog/2006/04/11/with-statement-considered-harmful/ I built some examples to investigate - and later try to "eliminate"
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.