answer warning: assignment from incompatible pointer type for linklist arrayに答えている間、キーワードでパーシードされた宣言されていない識別子struct
は、前方宣言された識別子と見なされることに気付きました。
たとえば、以下のプログラムはうまくコンパイルされます。
/* Compile with "gcc -std=c99 -W -Wall -O2 -pedantic %" */
#include <stdio.h>
struct foo
{
struct bar *next; /* Linked list */
};
int main(void) {
struct bar *a = 0;
struct baz *b = 0;
struct foo c = {0};
printf("bar -> %p\n", (void *)a);
printf("baz -> %p\n", (void *)b);
printf("foo -> %p, %zu\n", (void *)&c, sizeof c); /* Remove %zu if compiling with -ansi flag */
return 0;
}
私の質問:宣言されていないs を前方宣言された不完全な型としてC
扱うようにコンパイラを導くルールはどれですか?struct identifier
struct