Name
restrict
Synopsis
ANSI C99 introduces the type
qualifier restrict
, which is only applicable to
pointers. If a pointer declared with the restrict
qualifier points to an object that is to be modified, then the object
can only be accessed using that pointer. This information allows the
compiler to generate optimized machine code. It is up to the
programmer to ensure that the restriction is respected!
Example:
void *memcpy( void * restrict dest, // destination const void* restrict src, // source size_t n );
In using the standard function memcpy()
to copy a
memory block of n
bytes, the programmer must
ensure that the source and destination blocks do not overlap.
Get C Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.