By using the restrict
keyword like this:
int f(int* restrict a, int* restrict b);
I can instruct the compiler that arrays a and b do not overlap. Say I have a structure:
struct s{
(...)
int* ip;
};
and write a function that takes two struct s
objects:
int f2(struct s a, struct s b);
How can I similarly instruct the compiler in this case that a.ip
and b.ip
do not overlap?
Check this pointer example , You might get some help.
If two pointers are declared as restrict then these two pointers doesnot overlap.
EDITED
Check this link for more examples
You can also use
restrict
inside a structure.Thus a compiler can assume that
a.ip
andb.ip
are used to refer to disjoint object for the duration of each invocation of thef2
function.