Example of the #pragma disjoint Preprocessor Directive

The following example shows the use of #pragma disjoint.

int a, b, *ptr_a, ptr_b;
#pragma disjoint(*ptr_a, b) // *ptr_a never points to b
#pragma disjoint(*ptr_b, a) // *ptr_b never points to a
one_function()
{
b = 6;
*ptr_a = 7; // Assignment will not change the value of b
another_function(b); // Argument "b" has the value 6
}

Because external pointer ptr_a does not share storage with and never points to the external variable b, the assignment of 7 to the object that ptr_a points to will not change the value of b. Likewise, external pointer ptr_b does not share storage with and never points to the external variable a. The compiler can assume that the argument to another_function has the value 6 and will not reload the variable from memory.



Preprocessor Directives


#pragma Preprocessor Directives
List of Preprocessor Directives