I understand what restrict
means, but I'm a little bit confused with such usage/syntax:
#include <stdio.h>
char* foo(char s[restrict], int n)
{
printf("%s %d\n", s, n);
return NULL;
}
int main(void)
{
char *str = "hello foo";
foo(str, 1);
return 0;
}
Successfully compiled with gcc main.c -Wall -Wextra -Werror -pedantic
How is restrict work in this case and interpret by the compiler?
gcc version: 5.4.0
restrict char *s
. – Bellyachechar * restrict s
? – Opinionatedrestrict char *s
produces a compiler error;char * restrict s
does not. – Bellyache