c - What is the __builtin_expect() prototype? -
to rid of static code analysis warning (qa-c), need provide function prototype __builtin_expect()
.
i using windriver diab compiler powerpc. in compiler manual have found following information:
__builtin_expect(long exp, long c)
: ...exp
return value.
so, prototype follows:
long __builtin_expect(long exp, long c);
however, not compile, getting following error:
error (dcc:1701): invalid types on prototype intrinsic __builtin_expect - when intrinsic enabled, optional user prototype must match
it seems prototype not correct. correct prototype __builtin_expect
?
the error message states user prototype optional. should possible define it, right?
you need somehow define __builtin_expect
make static analyzer happy, because doesn't know function is. need use #ifdef
disable definition when compiling program normally, because compiler not if try define compiler builtins yourself. builtins come compiler not supposed defined in program.
something work:
#ifdef _hey_i_am_running_static_analyzer #define __builtin_expect(e,c) (e) #endif
i don't know details of how static analyzer works, don't know right macro test in #ifdef
. can read documentation of static analyzer find out if defines preprocessor symbols default, or if can tell preprocessor symbols define when run it.
Comments
Post a Comment