How to Compare Visual Studio’s Debug and Release Configurations

Comparing Debug and Release configurations (or any other two configurations) is not easily done with visual studio.  However, there is a way to do it reasonably easily, since all the configurations setting  applied to a C++ project are translated to command line switches passed  on to the compiler or linker tools.
This method  allows easy comparison of the command line switches  of two configurations.

1. Open the Project properties and navigate to the Command Line entry:
Project –> Properties –> C/C++ –> Command Line
Select one of the configurations you  want to compare
Merge Release Property Pages

2.  Open an empty  text document in  a text editor supporting regular expressions. I’ve used Notepad++,  but you can also use Visual Studio itself by opening a new text file.
Paste the content of the All Option field  to the file. Append the  content of the Additional Options Field.

you should be getting something similar to this (word wrap view) :

3. The next steps will ensure there is  one option per line.  Most of the switches  have no spaces except  the /D switch.  I’ll remove it with a simple regex :
Search and Replace the regular expression
/D\s  with  /D   :

4.  Now  we can have one option per line  by searching and replacing \s  with \n   (spaces to newlines).

5.  Save the output to a file (e.g.  OptionsReleaseSplit.txt)
E__Examples_OptionsReleaseSplit.txt - Notepad

6.  Repeat the process to the other configuration you want to compare.

7.  Now comparing the two configurations is as easy as comparing the two files in a  Diff  tool :

A similar method can be applied to the linker’s options:
Merge Property Pages

That’s it,  the simple system saved me some guesswork when a project compiled in debug but will not compile (or link)  when using release configuration.
Do you have other ways of   comparing debug/release?    leave a note in the comment section.

Raw pointers are also Iterators!

Using raw pointers (a.k.a. naked pointers) is never a good first choice. Being high maintenance and error prone creatures, you’re far better off using one of the alternatives offered by the standard library.
Having said that, sometimes you simply do not have a choice. You might be working with a block of memory passed on by a hardware component, or you might be stuck with some critical legacy library that “just works” and nobody dares touch today.
In Any case, using  naked pointer doesn’t mean you have to go full commando yourself. Many of the STL algorithms would accept, with little or no complaints,  raw pointers. an iterator is, after all , a  generalized  pointer:

#include <iostream>
#include <algorithm>
#include <array>
using namespace std;

void PrintArray( int* pBegin, int* pEnd)
	cout << *pBegin++;
	for_each(pBegin, pEnd,[](int i) { cout << ',' << i; } );
	cout << endl << endl;

int main()
	// an integer array
	const auto integer_list =  { 19,14,3,5,20,11,10,18,1,17,9,6,7,2,13,12,4,16,8,15 };
	const size_t block_size = integer_list.size();
	int* pMemBlock = new int[block_size];
	int* pBegin = pMemBlock;
	int* pEnd = (pBegin + block_size);

	//copy the content of the initializer list to the memory block 
	std::copy(integer_list.begin(), integer_list.end(), pBegin);
	cout << "The list of numbers in the memory block:" << endl;
	PrintArray(pBegin, pEnd);

	int count = count_if(pBegin, pEnd, [](int n) {return  n < 5; });
	cout << count  <<  " numbers are less than 5\n" <<  endl;
	std::sort(pBegin, pEnd);
	cout << "sorted list:" << endl;
	PrintArray(pBegin, pEnd);
	cout << endl;
	random_shuffle(pBegin, pEnd);

	cout << "shuffled  list:" << endl;
	PrintArray(pBegin, pEnd);

	delete[] pMemBlock;

The list of numbers in the memory block:

4 numbers are less than 5

sorted list:

shuffled list:

Since the array size is not known at compile time, it’s up to you to accurately calculate the begin and end  pointers (lines 22,23) ,  once these pointers contain the proper addresses,  they can be passed around  just like any other iterator.

note:  if it was a static array, it would have been possible to apply the begin() and end() functions  (overloaded for static arrays by the standard library):

	int arr[]{ 28,4,26,21,20,22,11,12,14,8,17,30,13,15,9,7,19,1,16 };
	cout << "The list of numbers in the static array :" << endl;
	PrintArray(begin(arr), end(arr));