C语言玩耍02|C语言玩耍02 - include conflicts

【C语言玩耍02|C语言玩耍02 - include conflicts】今天玩耍的是include conflicts
如果你include多个header文件,要保证里面没有冲突的定义。
比如这样:
header1.h

typedef char yes_t[6];

header2.h
typedef char yes_t[7];

main.c
#include #include #include int main(int argc, char **argv) { yes_t a = "Yes!"; puts(a); return 0; }

gcc -o test -I. test.c
In file included from test.c:2:0: ./header2.h:1:14: error: conflicting types for ‘yes_t’ typedef char yes_t[7]; ^~~~~ In file included from test.c:1:0: ./header1.h:1:14: note: previous declaration of ‘yes_t’ was here typedef char yes_t[6]; ^~~~~

但是如果都是yes_t[6]; ,那就没事了。

    推荐阅读