Xcode:类型'struct dirent'在不同的翻译单元中具有不兼容的定义

时间:2018-04-27 18:46:40

标签: c xcode llvm xv6

我正在尝试使用xv6的fs.h头文件构建程序。

我的Xcode项目中只有三个文件:type.h(未修改),fs.h(未修改)和def splitAtUpperCase(s): for i in range(len(s)-1)[::-1]: if s[i].isupper() and s[i+1].islower(): s = s[:i]+' '+s[i:] if s[i].isupper() and s[i-1].islower(): s = s[:i]+' '+s[i:] return s.split() splitAtUpperCase('TheLongANDWindingRoad') >>> ['The', 'Long', 'AND', 'Winding', 'Road'] ,如下所示。

main.c

在命令行#include <stdio.h> #include "types.h" #include "fs.h" int main(int argc, const char * argv[]) { // insert code here... printf("Hello, World!\n"); return 0; } 中使用gcc成功构建此程序,但Xcode在gcc -o main main.c -I .中一直给我一个错误(Apple LLVM 9.0错误):

  

类型'struct dirent'在不同的翻译单元中具有不兼容的定义

如果我将fs.h中的struct dirent名称替换为任何其他名称,则可以构建。

我该如何解决?

修改

运行fs.h

的输出
gcc -o main main.c -I . -H

以下是来自Xcode的错误消息:

error error

点击“文件名为'd_ino'此处”弹出. /usr/include/stdio.h .. /usr/include/_stdio.h ... /usr/include/sys/cdefs.h .... /usr/include/sys/_symbol_aliasing.h .... /usr/include/sys/_posix_availability.h ... /usr/include/Availability.h .... /usr/include/AvailabilityInternal.h ... /usr/include/_types.h .... /usr/include/sys/_types.h ..... /usr/include/machine/_types.h ...... /usr/include/i386/_types.h ..... /usr/include/sys/_pthread/_pthread_types.h ... /usr/include/sys/_types/_va_list.h .... /usr/include/machine/types.h ..... /usr/include/i386/types.h ...... /usr/include/sys/_types/_int8_t.h ...... /usr/include/sys/_types/_int16_t.h ...... /usr/include/sys/_types/_int32_t.h ...... /usr/include/sys/_types/_int64_t.h ...... /usr/include/sys/_types/_u_int8_t.h ...... /usr/include/sys/_types/_u_int16_t.h ...... /usr/include/sys/_types/_u_int32_t.h ...... /usr/include/sys/_types/_u_int64_t.h ...... /usr/include/sys/_types/_intptr_t.h ....... /usr/include/machine/types.h ...... /usr/include/sys/_types/_uintptr_t.h ... /usr/include/sys/_types/_size_t.h ... /usr/include/sys/_types/_null.h ... /usr/include/sys/stdio.h .. /usr/include/sys/_types/_off_t.h .. /usr/include/sys/_types/_ssize_t.h .. /usr/include/secure/_stdio.h ... /usr/include/secure/_common.h . ./types.h . ./fs.h 的Xcode编辑器。这是否意味着它与macOS系统定义存在冲突?

dirent.h

0 个答案:

没有答案