我正在使用带有 C99 标准的 mingw32-gcc。restrict
我在下面的代码中粘贴了一些关于关键字的文章的编辑- http://wr.informatik.uni-hamburg.de/_media/teaching/wintersemester_2013_2014/epc-1314-fasselt-c-keywords-report.pdf。根据作者的说法,"Result One"
应该"Result Two"
是不同的,但是当我运行它时,它们是相同的。我没有收到任何编译器警告。有没有我遗漏的设置?
#include <stdio.h>
void update(int* a, int* b, int* c)
{
*a += *c;
*b += *c;
}
void update_restrict(int* a, int* b, int* restrict c)
{
printf("*c = %d\n",*c);
*a += *c;
printf("\n*c = %d - ",*c);
printf("shouldn't this have stayed the same?\n\n");
*b += *c;
}
int main()
{
int a = 1, b = 2;
update(&a, &b, &a);
printf("Result One: a, b = %d, %d\n", a, b);
a = 1; b = 2; // reset values
update_restrict(&a, &b, &a);
printf("Result Two: a, b = %d, %d\n", a, b);
getchar();
return 0;
}