josh's WebLog

Visual C++ IDE from the trenches

understanding the VC project system part II: configurations and the project property pages dialog

my last entry talked about the files that are contained in a project. this entry is going to discuss the next important collection of items in the project: the configurations.

a configuration is really nothing more than a collection of property values. for instance, in a "debug" configuration the "optimization" property on the C++ compiler tool is usually set to "disabled" (/Od), while in a "release" configuration it is usually set to something like "maximize speed" (/O2). because they control what is built, and how, they are often likened to a "target" in a makefile, although they are not exactly the same.

when you bring up the project properties dialog, the configuration that you are actually manipulating is shown in the upper left in a combo-box control. you can change the configuration and see that the property values below change. you can also select "all configurations" to set properties on all of the configurations simultaneously, but this has one potential danger: any property that is different in different configurations will show as blank. it is easy to accidentally enter a value in a blank property and overwrite that value on all the configurations. (this is particularly insidious with things like the c++ compiler's "preprocessor definitions" property, which consists of a list of strings that is quite often different across configurations. if you type into the blank field and apply the change you have not added new preprocessor definitions to all the configs, like you might think, but have instead replaced all of them with what you just typed).

when browsing through the pages in the property pages dialog one thing you might notice is that some properties are shown in a bold font while others are not. the bold font indicates that the property in question has overridden the value of the property. in other words, if the property value is not bold, the property is in its default state and has not been set.

a project can contain any number of configurations. the VC application wizards generate only two by default, debug and release, but you can add any number of them. for maintainabilities' sake I recommend only creating as many as you actually need. many things that you might be tempted to create a new configuration for can actually be better handled by using project system macros. which is exactly what i'll be discussing in my next entry...
Published Wednesday, February 04, 2004 5:33 PM by josh_

Comments

 

Chris Monachan said:

Perhaps this is a topic for a future blog, but I've seen it asked frequently in news groups and never seen an answer to it:

Why are the project files not real XML? (I.e. they break if you change the attribute order in certain nodes.)

For an number of reasons we find that we have to write support tools to help maintain project configurations. The extra step we have to go through in order to get the IDE to accept the file as valid (putting the name attribute at the start of any node), always confused me.
February 5, 2004 5:33 AM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker