In the C programming language (after 99 standard), a new keyword is introduced known as restrict.
- 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 optimizations 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 and compiler doesn’t need to add any additional checks.
- If a programmer uses restrict keyword and violate the above condition, result is undefined behavior.
- restrict is not supported by C++. It is a C only keyword.
120 130 70
This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Difference between const char *p, char * const p and const char * const p
- Pointer to an Array | Array Pointer
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Dangling, Void , Null and Wild Pointers
- NULL pointer in C
- What are near, far and huge pointers?
- Data Types in C
- Function Pointer in C
- Generic Linked List in C
- Enumeration (or enum) in C
- Union in C
- Commonly Asked C Programming Interview Questions | Set 1
- Memory Layout of C Programs
- Pointer vs Array in C
- How to declare a pointer to a function?