Setting up Application Project Properties in Visual Studio .NET 2003


Visual Studio C++ Code Generation Properties

Here we will examine the C++ Compiler Code Generation Properties Tab.



Enable Minimal Rebuild
This will make the compiler only rebuild files that have changed since the last build attempt.

Setting this will greatly speed up compile times; however, you should do a complete rebuild of the project periodically (especially after syncing to the lastest revision in the source control depot).


Enable C++ Exceptions
This allows C++ exceptions to be thrown and handled within your project. Also, when an exception is thrown this options makes sure that destructor are called for automatic objects when the stack is unwound.

Even if you are not working with exceptions in your code, you should keep this option on.


Basic Runtime Checks
This tells the compiler to check for a few different simple runtime errors:

  • Data loss through type conversion
  • Stack frame runtime errors
  • Use of an uninitialized variable

Data loss through type conversion means that you are performing an operation where a larger (in bits) data type is being assigned into a smaller one without an explicit conversion.

A commmon example of this is assigning a double to a float:
   double d = 1234.5678;
   float  f = d;            // possible loss of data through implicit conversion
In this case you should perform an explicit type-cast:
   double d = 1234.5678;
   float  f = (float) d;    // explicit conversion
There are a few stack frame runtime errors that the compiler will check for:
  • Uninitialized stack local variables
  • Stack overruns and underruns
  • Stack pointer corruption

Use of an uninitialized variable should be self-explanitory.

As stated before, during a Debug build there is much incentive to make the compiler as powerful as possible. Thus, it is suggested that the all of these runtime checks are turned on: enable the "Both" option.


Runtime Library
This indicates which Standard C++ Runtime Library will be included with your project. Microsoft has compiled their version of the Standard C++ Runtime Library into different forms to suit different project needs. Choices include:

  • Multi-threaded
  • Multi-threaded Debug
  • Multi-threaded DLL
  • Multi-threaded Debug DLL
  • Single-threaded
  • Single-threaded Debug

WARNING! This may be subject to change depending upon what libraries you are linking into your project. When starting out, I suggest you stick with Multi-threaded Debug and Multi-threaded for Debug and Release versions, respectively. If the libraries you use require a different setting, you should comply as best you can...
this setting can be the source of many headaches...


Stuct Member Alignment
By setting this option, the compiler will pack members of the struct's in your code to be aligned on a particular byte boundary. Choices include:

  • Default
  • 1 Byte
  • 2 Bytes
  • 4 Bytes
  • 8 Bytes
  • 16 Bytes

This setting is important when it comes to networking and vectorized instructions. You should adjust this option accoridingly.


Enable Enhanced Instruction Set
This option will allow the compiler to attempt to utilize SIMD instructions when compiling your code. This option should be the same for both Debug and Release builds to ensure consistency in the instruction sets being used. Choices include:

  • Not Set
  • Streaming SIMD Extensions (SSE)
  • Streaming SIMD Extensions 2 (SSE2)

Most machines now support enhanced instruction sets. However, SSE2 is not as widely accepted and only available in Intel P4's (last time I checked). SSE instructions are agreed upon by both Intel (as of P3) and AMD (as of Athlon(?)). If you choose to use this option, only use SSE.





<< Previous

:: Index ::

Next >>