user763410
user763410

Reputation: 562

Clang. How to overcome "unknown builtin" error message

I have a program that setups clang compiler instance and adds include paths using HeaderSearchOptions class. When I run ParseAst on the input file libavutil/samplefmt.c (from ffmpeg package), I get the following message on the screen. Basically, it is not able to resolve some (gcc?) builtin functions. How do I get rid of this error? In general, If setting include path through HeaderSearchOptions, how do I ensure I don't miss out on all include paths from my gcc installation?

Thanks!

#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'

Upvotes: 3

Views: 3260

Answers (1)

Carl Norum
Carl Norum

Reputation: 224982

Something must have gone funny when you did your project configuration. The ff_log2 code, for example, is inside:

#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)

So you need to make sure HAVE_FAST_CLZ isn't defined, and you should be ok on that front. You can do similar things to fix the strcmp.

Upvotes: 4

Related Questions