Menu

Cppcheck 2.10 not able to analyze a file

vix
2023-01-30
2023-02-08
  • vix

    vix - 2023-01-30

    I used Cppcheck 2.10 to analyze the source code of QCBOR library https://github.com/laurencelundblade/QCBOR
    I get a message on qcbor\qcbor_decode.c saying

    This file is not analyzed. Cppcheck failed to extract a valid configuration. The tested configurations have these preprocessor errors:
    '' : [D:/xxxxx/QCBOR-1.2/src/qcbor_decode.c:1023] #error QCBOR_TYPE_BYTE_STRING no lined up with major type
    QCBOR_DISABLE_FLOAT_HW_USE : [D:/xxxxx/QCBOR-1.2/src/qcbor_decode.c:1023] #error QCBOR_TYPE_BYTE_STRING no lined up with major type
    QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS : [D:/xxxxx/QCBOR-1.2/src/qcbor_decode.c:1023] #error QCBOR_TYPE_BYTE_STRING no lined up with major type
    QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS : [D:/xxxxx/QCBOR-1.2/src/qcbor_decode.c:1023] #error QCBOR_TYPE_BYTE_STRING no lined up with major type
    QCBOR_DISABLE_TAGS : [D:/xxxxx/QCBOR-1.2/src/qcbor_decode.c:1023] #error QCBOR_TYPE_BYTE_STRING no lined up with major type
    _MSC_VER : [D:/xxxxx/QCBOR-1.2/src/qcbor_decode.c:1023] #error QCBOR_TYPE_BYTE_STRING no lined up with major type
    

    But looking to line 1022 of qcbor_decode.c I see
    #if CBOR_MAJOR_TYPE_BYTE_STRING + 4 != QCBOR_TYPE_BYTE_STRING
    and this expands to
    CBOR_MAJOR_TYPE_BYTE_STRING as 2
    and
    QCBOR_TYPE_BYTE_STRING as 6
    defined in the include files qcbor_common.h and qcbor_decode.h

    I don't understand the reason for the messages, and the reason why the file is not analyzed.

    Thanks

     
  • Daniel Marjamäki

    it works for me:

    $ ~/cppcheck/cppcheck -Iinc src/qcbor_decode.c
    Checking src/qcbor_decode.c ...
    Checking src/qcbor_decode.c: QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA...
    Checking src/qcbor_decode.c: QCBOR_DISABLE_FLOAT_HW_USE...
    ...

     

    Last edit: Daniel Marjamäki 2023-02-01
  • vix

    vix - 2023-02-07

    I tried with cppcheck on my Windows 10 machine.
    If I try to run
    cppcheck,exe -I inc --force src/qcbor_decode.c
    from the command line, it works.

    But if I try from the GUI Analyze >> Files and I select qcbor_decode.c I get the above error.
    Even if I have enabled Edit >> Preferences >> General >> Force checking all #ifdef configurations

    I think that the trick is passing the -I option to the command line.
    How can I pass an include folder from the GUI?

     
    • Daniel Marjamäki

      Please create a cppcheck project. In the GUI:
      * File menu
      * New Project...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.