Restrict is introduced by c99. It can only be used to restrict pointers and indicates that pointers are the only and initial method to access a data object. the object can be accessed only when the second pointer is based on the first pointer. consider the following example: int ar [10]; int * restrict restar = (int *) malloc (10 * sizeof (int); int * par = ar; the restar is the only and initial method to access the memory allocated by malloc. No. So: [cpp] for (n = 0; n <10; n ++) {par [n] + = 5; restar [n] + = 5; ar [n] * = 2; par [n] + = 3; restar [n] + = 3;} Because restar is the only and initial way to access the allocated memory, then the compiler can optimize the restar operation: restar [n] + = 8; and par is not the only way to access the array ar, so the following optimization cannot be performed: par [n] + = 8; because before par [n] + = 3, ar [n] * = 2 is changed. With the keyword restric, the compiler can be optimized with confidence. Void * memcpy (void * restrict s1, const void * restrict s2, size_t n); if the copy happens between two overlapping objects, the behavior is uncertain. Void * memmove (void * s1, constvoid * s2, size_t n); Copying is not affected even if the two pointers point to different regions. It is worth noting that once you decide to use restrict to modify pointers, you must ensure that they do not overlap with each other and the compiler will not check for you. Void setbuf (FILE * restrict fp, char * restrict buf); indicates that the keyword "memory space not exceeded by fp and buf" is related to optimization. For example, www.2cto. comvoid func (int * a, int * B) {* a + = * B;} can be optimized to void func (int *, int * B) {* a + = * B <1;} but if a and B point to the same integer, the semantics of the two functions is different. Because of this risk, many compilers will not be so optimized. Now, with the restrict keyword added, the compiler can perform this optimization boldly. In addition, for optimization, the restrict and register keywords are built upon, while the volatile keywords are mandatory.