Quick Contact

✉
fahimkhan20148@gmail.com
📱
+971 507 286 133
Back to Notes
September 12, 2026
ctypesqualifiersrestrictarrays

Restrict in C

Used when we want to indicate that the same memory location can't be accessed by more than one pointer. So the compiler can apply some optimisations.

Making a pointer restrict and accessing it with another pointer is undefined behaviour.

int main() {
	int i = 10;
	int* restrict ptr = &i;
}

Function Argument Declarations

restrict qualifier can be used in argument declarations.

int move(size_t size, int destination[restrict static size], const int src[restrict static size]);

The above function accepts pointers of 2 arrays that are distinct and have no overlap.

Note: static size tells the compiler the array must have at least size elements and cannot be NULL.