Menu

There is syntaxError when use "-I /usr/include"

wy163
2026-01-14
2026-02-25
  • wy163

    wy163 - 2026-01-14

    Hi,

    For example, I have below code in main.c:

    #include <stdlib.h>
    
    int main() {
        return 0;
    }
    

    With "cppcheck main.c -I /usr/include", there will be error:

    error: failed to evaluate #if condition, undefined function-like macro invocation: __GLIBC_USE( ... ) [syntaxError]
    #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
    

    The checking process will be stopped by this error, and cppcheck exit. Is this normal?
    As you know, there also might be -I options in the commands of a compile_commands.json. So checking will not be completed if such a compile_commands.json is imported.
    Is there any method to avoid such errors? Thanks!

     
  • Oliver Stöneberg

    Already tracked in https://trac.cppcheck.net/ticket/14091 but the behavior changed. We need to treat this differently. I will file tickets about that soon.

    A workaround for this is define it yourself -D__GLIBC_USE(x)=(0) for now.

     

Log in to post a comment.

MongoDB Logo MongoDB