Menu

CppCheck appears to hang when nlohmann/json.hpp is included

MarkP
2024-03-20
2024-03-20
  • MarkP

    MarkP - 2024-03-20

    I am using CppCheck version 3.13.4 and have found that it has started to hang since I started using the nlohmann JSON library in my code.

    The following file demonstrates the issue:

     #include <nlohmann/json.hpp>
    
    int NLohmanTest() {
        return 0;
    }
    

    My comamnd line for building it is:

    cppcheck --xml --xml-version=2 --suppress=missingInclude 
          --suppress=missingIncludeSystem --suppress=unusedFunction 
          --suppress=unmatchedSuppression --suppress=functionStatic 
         --suppress=funcArgNamesDifferent --suppress=*:*_deps/* 
         --enable=all --debug --verbose --debug-warnings --report-progress 
         --showtime=file --inline-suppr --inconclusive 
         --config-exclude=build/Ubuntu-x64/_deps/ 
          simple-test.cpp -I build/Ubuntu-x64/_deps/nlohmann_json-src/include/
    

    This shows that the file is being compiled multiple times with different options, e.g

    Checking Common/src/simple-test.cpp: JSON_ASSERT...
    Checking Common/src/simple-test.cpp: JSON_CATCH_USER...
    Checking Common/src/simple-test.cpp: JSON_DIAGNOSTICS...
    Checking Common/src/simple-test.cpp: JSON_HAS_CPP_11;JSON_HAS_CPP_14;JSON_HAS_CPP_17;JSON_HAS_CPP_20...
    Checking Common/src/simple-test.cpp: JSON_HAS_CPP_11;JSON_HAS_CPP_14;JSON_HAS_CPP_17;JSON_HAS_CPP_20;_HAS_CXX14...
    Checking Common/src/simple-test.cpp: JSON_HAS_CPP_11;JSON_HAS_CPP_14;JSON_HAS_CPP_17;JSON_HAS_CPP_20;_HAS_CXX17...
    Checking Common/src/simple-test.cpp: JSON_HAS_CPP_11;JSON_HAS_CPP_14;JSON_HAS_CPP_17;JSON_HAS_CPP_20;_MSVC_LANG...
    Checking Common/src/simple-test.cpp: JSON_HAS_CPP_17...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_ALWAYS_INLINE;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_ARM_VERSION;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_ARM_VERSION_CHECK;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_ARRAY_PARAM;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_ASSUME;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_BEGIN_C_DECLS;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_CLANG_HAS_ATTRIBUTE;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_CLANG_HAS_BUILTIN;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE;JSON_HEDLEY_VERSION...
    Checking Common/src/simple-test.cpp: JSON_HEDLEY_CLANG_HAS_EXTENSION;JSON_HEDLEY_VERSION...

    how can I prevent this?

     

    Last edit: MarkP 2024-03-20
  • MarkP

    MarkP - 2024-03-20

    turns out that adding

         --config-exclude=build/Ubuntu-x64/_deps/ 
    

    Appears to fix it ...

    is there a way to use a 'simplified' path as the _deps directory is normally created by cmake which depends on teh build config?

    something like:

         --config-exclude=**_deps/ 
    
     

    Last edit: MarkP 2024-03-20

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.