一、报错提示-不完全类型(has incomplete type)
Compiling obj/main.o from main.c..
arm-linux-gcc -g -w -std=gnu99 -DLINUX -I./ -Inmealib/inc/ -c -o obj/main.o main.c
In file included from /home/user/Desktop/nuc980-sdk/sdk/arm_linux_4.8/usr/include/sys/stat.h:107:0,from main.c:7:
/home/user/Desktop/nuc980-sdk/sdk/arm_linux_4.8/usr/include/bits/stat.h:72:21: error: field ‘st_atim’ has incomplete typestruct timespec st_atim; /* Time of last access. */^
/home/user/Desktop/nuc980-sdk/sdk/arm_linux_4.8/usr/include/bits/stat.h:73:21: error: field ‘st_mtim’ has incomplete typestruct timespec st_mtim; /* Time of last modification. */^
/home/user/Desktop/nuc980-sdk/sdk/arm_linux_4.8/usr/include/bits/stat.h:74:21: error: field ‘st_ctim’ has incomplete typestruct timespec st_ctim; /* Time of last status change. */^
In file included from main.c:7:0:
/home/user/Desktop/nuc980-sdk/sdk/arm_linux_4.8/usr/include/sys/stat.h:365:33: error: array type has incomplete element type__const struct timespec __times[2],^
/home/user/Desktop/nuc980-sdk/sdk/arm_linux_4.8/usr/include/sys/stat.h:372:56: error: array type has incomplete element typeextern int futimens (int __fd, __const struct timespec __times[2]) __THROW;^
make: *** [makefile:83: obj/main.o] Error 1
二、原因
这种情况是由工程中include的头文件里有一个与系统中的头文件重名了,因此编译器查找头文件时,是查找的你工程中或者其他非系统路径下的头文件,导致系统中的头文件不再被包含了,因此找不到变量或结构体的声明。工程中因为移植的工程中有个time.h的头文件,而系统中已经有了一个time.h,因此冲突了。
三、解决办法
将移植的库文件 time.h 文件改成其它名字。
注意:移植的库文件中所有include此头文件的地方都需要改动。