什么会导致编译器随机失败?

时间:2014-12-11 15:47:12

标签: clang

我在windows上使用clang编译器。我使用了LLVM网站上的安装程序。有时它会给我一个编译器错误。

clang -I./include main.c CoreFoundation.dll

它给出了:

In file included from main.c:4:
In file included from ./include\CoreFoundation/CFNumberFormatter.h:110:
./include\CoreFoundation/CFXMLParser.h:159:81: error: unknown type name 'CFXMLNodeRef'
typedef void *          (*CFXMLParserCreateXMLStructureCallBack)(CFXMLParserRef parser, 

CFXMLNodeRef nodeDesc, void *info);
...

有时这个..

In file included from main.c:4:
In file included from ./include\CoreFoundation/CoreFoundation.h:86:
./include\CoreFoundation/CFDateFormatter.h:104:105: error: unknown type name 'CFDateRef'; did you mean 'CFDataRef'?
CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
...

......和其他类似的警告,似乎随机选择停在哪里。有时它会毫无错误地编译。当它给出错误时,它们似乎是在找不到包含文件中的符号。它没有抱怨没有找到该文件。但它并没有始终停留在同一点,有时会成功编译。

1 个答案:

答案 0 :(得分:2)

我可以使用gcc在Linux下重现这个“错误”。我甚至得到了“报告此编译器错误请”的消息。

  

当它出错时,它们似乎是在找不到包含文件中的符号

你可以得到这个:

  1. 如果使用多个线程进行编译(例如make -j8)
  2. 如果您中止编译然后再次启动它而不“清除”所有obj文件
  3. 如果您编译了源代码,更改了某些内容并在没有“清理”的情况下进行编译
  4. 如果你的编译器/ make / build进程每次都改变顺序......(用cmake和opencv 3源代码)
相关问题