c++ - 铛。如何克服 "unknown builtin"错误消息

标签 c++ c gcc compiler-construction clang

我有一个程序可以设置 clang 编译器实例并使用 HeaderSearchOptions 类添加包含路径。当我在输入文件 libavutil/samplefmt.c(来自 ffmpeg 包)上运行 ParseAst 时,我在屏幕上收到以下消息。基本上,它无法解析某些(gcc?)内置函数。我如何摆脱这个错误?一般来说,如果通过 HeaderSearchOptions 设置包含路径,我如何确保我不会错过我的 gcc 安装中的所有包含路径?

谢谢!

#include "..." search starts here:
#include <...> search starts here:
 .
 /usr/include/freetype2
 /usr/include/fribidi
 /usr/local/include
 /usr/include/clang/Basic
 /opt/llvmrelease/bin/../lib/clang/3.4/include
 /usr/include/i386-linux-gnu
 /include
 /usr/include
End of search list.
In file included from libavutil/samplefmt.c:19:
libavutil/common.h:258:12: error: use of unknown builtin '__builtin_clz'
    return av_log2((x - 1) << 1); 
           ^
libavutil/intmath.h:89:23: note: expanded from macro 'av_log2'
#define av_log2       ff_log2
                      ^
libavutil/intmath.h:45:29: note: expanded from macro 'ff_log2'
#   define ff_log2(x) (31 - __builtin_clz((x)|1))
                            ^
libavutil/samplefmt.c:59:14: error: use of unknown builtin '__builtin_strlen'
        if (!strcmp(sample_fmt_info[i].name, name))
             ^
/usr/include/i386-linux-gnu/bits/string2.h:804:22: note: expanded from macro 'strcmp'
      && (__s1_len = __builtin_strlen (s1), __s2_len = __builtin_strlen (s2), \
                     ^
libavutil/samplefmt.c:59:14: note: did you mean '__builtin_strchr'?
/usr/include/i386-linux-gnu/bits/string2.h:804:22: note: expanded from macro 'strcmp'
      && (__s1_len = __builtin_strlen (s1), __s2_len = __builtin_strlen (s2), \
                     ^
libavutil/samplefmt.c:59:14: error: use of unknown builtin '__builtin_strcmp'
        if (!strcmp(sample_fmt_info[i].name, name))
             ^
/usr/include/i386-linux-gnu/bits/string2.h:807:9: note: expanded from macro 'strcmp'

最佳答案

当您进行项目配置时,一定发生了一些有趣的事情。例如ff_log2代码在里面:

#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)

因此您需要确保 HAVE_FAST_CLZ 未定义,您应该在这方面没问题。您可以执行类似的操作来修复 strcmp

关于c++ - 铛。如何克服 "unknown builtin"错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18299125/

相关文章:

c - 尝试使用 scanf 中的数据时出现段错误?

c++ - 错误 : ‘int pow(double, int)’ conflicts with a previous declaration int pow(double a, int n) {

c++ - 为什么 operator-> 可以手动重载?

c++ - Clang:模板推导失败 'double' 与 '<double>'

c++ - CoCreate IWICImagingFactory 实例

c - %n 如何处理变量

c++ - 更改项目中变量名称的最安全方法

c - 如何在 C 中的 fork 进程中查找共享/复制的内存页

ubuntu - 错误 : command 'x86_64-linux-gnu-gcc' failed with exit status 1

c - 如何防止 gcc 预处理器删除行继续符?