次のプログラムをコンパイルすると、エラーが発生します。
gcc tester.c -o tester
tester.c: In function ‘main’:
tester.c:7:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptr_X’
tester.c:7:17: error: ‘ptr_X’ undeclared (first use in this function)
tester.c:7:17: note: each undeclared identifier is reported only once for each function it appears in
tester.c:10:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ptr_Y’
tester.c:10:17: error: ‘ptr_Y’ undeclared (first use in this function)
#include <stdio.h>
int main() {
int x = 10;
int y = 20;
int *restrict ptr_X;
ptr_X = &x;
int *restrict ptr_Y;
ptr_Y = &y;
printf("%d\n",*ptr_X);
printf("%d\n",*ptr_Y);
}
なぜこれらのエラーが発生するのですか?