Binary incompatibility, accessing a member or even worse, calling a function of the wrong class:
#pragma once
//include1.h:
#ifndef classw
#define classw
class class_w
{
public: int a, b;
};
#endif
A function uses it, and it is ok:
//functions.cpp
#include <include1.h>
void smartFunction(class_w& x){x.b = 2;}
Bringing in another version of the class:
#pragma once
//include2.h:
#ifndef classw
#define classw
class class_w
{
public: int a;
};
#endif
Using functions in main, the second definition changes the class definition. It leads to binary incompatibility and simply crashes at runtime. And fix the issue by removing the first include in main.cpp:
//main.cpp
#include <include2.h> //<-- Remove this to fix the crash
#include <include1.h>
void smartFunction(class_w& x);
int main()
{
class_w w;
smartFunction(w);
return 0;
}
None of variants generates a compile or link time error.
The vice versa situation, adding an include fixes the crash:
//main.cpp
//#include <include1.h> //<-- Add this include to fix the crash
#include <include2.h>
...
These situations are even much more difficult when fixing bug in an old version of program, or using an external library/dll/shared object. That's why sometimes must be followed the rules of binary backward compatibility.
#include
d.#include <vld.h>
in a strategic position in your code. Removing or adding that VLD header does not "break" the program, but it affects the runtime behavior significantly. I have seen VLD slow down a program to the point that it became unusable.