usage:
restrict keyword is mainly used in pointer declarations as a type qualifier for pointers.
It doesn’t add any new functionality.
It is only a way for programmer to inform about an optimization that compiler can make.
When we use restrict with a pointer ptr, it tells the compiler that ptr is the only way to access the object pointed by it
in other words, there’s no other pointer pointing to the same object
i.e. restrict keyword specifies that a particular pointer argument does not alias any other
and the compiler doesn’t need to add any additional checks.
note:
If a programmer uses restrict keyword and violate the above condition, the result is undefined behavior.
restrict is not supported by C++.
It is a C only keyword.