{"id":13417878,"url":"https://github.com/danmar/cppcheck","last_synced_at":"2025-05-12T11:15:50.331Z","repository":{"id":515183,"uuid":"143131","full_name":"danmar/cppcheck","owner":"danmar","description":"static analysis of C/C++ code","archived":false,"fork":false,"pushed_at":"2025-05-12T08:26:14.000Z","size":169673,"stargazers_count":6145,"open_issues_count":150,"forks_count":1488,"subscribers_count":212,"default_branch":"main","last_synced_at":"2025-05-12T11:15:43.663Z","etag":null,"topics":["c","c-plus-plus","cpp","cppcheck","cross-platform","static-analysis"],"latest_commit_sha":null,"homepage":"https://cppcheck.sourceforge.io/","language":"C++","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danmar.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2009-03-04T20:16:45.000Z","updated_at":"2025-05-12T08:26:18.000Z","dependencies_parsed_at":"2023-02-16T23:15:56.882Z","dependency_job_id":"f605bd4b-1b56-4666-97f1-c67590631b6c","html_url":"https://github.com/danmar/cppcheck","commit_stats":null,"previous_names":[],"tags_count":115,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmar%2Fcppcheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmar%2Fcppcheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmar%2Fcppcheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danmar%2Fcppcheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danmar","download_url":"https://codeload.github.com/danmar/cppcheck/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253726900,"owners_count":21954095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c-plus-plus","cpp","cppcheck","cross-platform","static-analysis"],"created_at":"2024-07-30T22:00:54.652Z","updated_at":"2025-05-12T11:15:50.311Z","avatar_url":"https://github.com/danmar.png","language":"C++","readme":"# **Cppcheck** \n\n|release-windows|OSS-Fuzz|Coverity Scan Build Status|include-what-you-use|License|\n|:--:|:--:|:--:|:--:|:--:|\n|[![release-windows](https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml/badge.svg?branch=main)](https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml)|[![OSS-Fuzz](https://oss-fuzz-build-logs.storage.googleapis.com/badges/cppcheck.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened\u0026can=1\u0026q=proj:cppcheck)|[![Coverity Scan Build Status](https://img.shields.io/coverity/scan/512.svg)](https://scan.coverity.com/projects/512)|[![include-what-you-use](https://github.com/danmar/cppcheck/actions/workflows/iwyu.yml/badge.svg?branch=main)](https://github.com/danmar/cppcheck/actions/workflows/iwyu.yml)|[![License](https://img.shields.io/badge/license-GPL3.0-blue.svg)](https://opensource.org/licenses/GPL-3.0)\n\n\n## About the name\n\nThe original name of this program was \"C++check\", but it was later changed to \"Cppcheck\".\n\nDespite the name, Cppcheck is designed for both C and C++.\n\n## Manual\n\nA manual is available [online](https://cppcheck.sourceforge.io/manual.pdf).\n\n## Donate CPU\n\nCppcheck is a hobby project with limited resources. You can help us by donating CPU (1 core or as many as you like). It is simple:\n\n 1. Download (and extract) Cppcheck source code.\n 2. Run:\n    ```\n    cd cppcheck/\n    virtualenv .env\n    .env/bin/pip install -r tools/donate-cpu-requirements.txt\n    .env/bin/python tools/donate-cpu.py\n    ```\n\nThe script will analyse debian source code and upload the results to a cppcheck server. We need these results both to improve Cppcheck and to detect regressions.\n\nYou can stop the script whenever you like with Ctrl C.\n\n## Compiling\n\nCppcheck requires a C++ compiler with (partial) C++11 support. Minimum required versions are GCC 5.1 / Clang 3.5 / Visual Studio 2015.\n\nTo build the GUI application, you need to use the CMake build system.\n\nWhen building the command line tool, [PCRE](http://www.pcre.org/) is optional. It is used if you build with rules.\n\nThere are multiple compilation choices:\n* CMake - cross platform build tool\n* Windows: Visual Studio\n* Windows: Qt Creator + MinGW\n* GNU make\n* GCC (g++)\n* Clang (clang++)\n\nThe minimum required Python version is 3.6.\n\n### CMake\n\nThe minimum required version is CMake 3.13.\n\nExample, compiling Cppcheck with cmake:\n\n```shell\nmkdir build\ncd build\ncmake ..\ncmake --build .\n```\n\nIf you want to compile the GUI you can use the flag.\n-DBUILD_GUI=ON\n\nFor rules support (requires pcre) use the flag.\n-DHAVE_RULES=ON\n\nFor release builds it is recommended that you use:\n-DUSE_MATCHCOMPILER=ON\n\nFor building the tests use the flag.\n-DBUILD_TESTS=ON\n\nUsing cmake you can generate project files for Visual Studio,XCode,etc.\n\n#### Building a specific configuration\n\nFor single-configuration generators (like \"Unix Makefiles\") you can generate and build a specific configuration (e.g. \"RelWithDebInfo\") using:\n\n```shell\nmkdir build_RelWithDebInfo\ncd build_RelWithDebInfo\ncmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\ncmake --build . --config RelWithDebInfo\n```\n\nFor multi-configuration generators (like \"Visual Studio 17 2022\") the same is achieved using:\n\n```shell\nmkdir build\ncd build\ncmake ..\ncmake --build . --config RelWithDebInfo\n```\n\n### Visual Studio\n\nUse the cppcheck.sln file. The file is configured for Visual Studio 2019, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.\n\nTo compile with rules, select \"Release-PCRE\" or \"Debug-PCRE\" configuration. pcre.lib (pcre64.lib for x64 builds) and pcre.h are expected to be in /externals then. A current version of PCRE for Visual Studio can be obtained using [vcpkg](https://github.com/microsoft/vcpkg).\n\n### Visual Studio (from command line)\n\nIf you do not wish to use the Visual Studio IDE, you can compile cppcheck from the command line the following command.\n\n```shell\nmsbuild cppcheck.sln\n```\n\n### VS Code (on Windows)\n\nInstall MSYS2 to get GNU toolchain with g++ and gdb (https://www.msys2.org/).\nCreate a settings.json file in the .vscode folder with the following content (adjust path as necessary):\n\n```\n{\n    \"terminal.integrated.shell.windows\": \"C:\\\\msys64\\\\usr\\\\bin\\\\bash.exe\",\n    \"terminal.integrated.shellArgs.windows\": [\n        \"--login\",\n    ],\n    \"terminal.integrated.env.windows\": {\n        \"CHERE_INVOKING\": \"1\",\n        \"MSYSTEM\": \"MINGW64\",\n    }\n}\n```\n\nRun \"make\" in the terminal to build cppcheck.\n\nFor debugging create a launch.json file in the .vscode folder with the following content, which covers configuration for debugging cppcheck and misra.py:\n\n```\n{\n    // Use IntelliSense to learn about possible attributes.\n    // Hover to view descriptions of existing attributes.\n    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387\n    \"version\": \"0.2.0\",\n    \"configurations\": [\n        {\n            \"name\": \"cppcheck\",\n            \"type\": \"cppdbg\",\n            \"request\": \"launch\",\n            \"program\": \"${workspaceFolder}/cppcheck.exe\",\n            \"args\": [\n                \"--dump\",\n                \"${workspaceFolder}/addons/test/misra/misra-test.c\"\n            ],\n            \"stopAtEntry\": false,\n            \"cwd\": \"${workspaceFolder}\",\n            \"environment\": [],\n            \"externalConsole\": true,\n            \"MIMode\": \"gdb\",\n            \"miDebuggerPath\": \"C:/msys64/mingw64/bin/gdb.exe\",\n            \"setupCommands\": [\n                {\n                    \"description\": \"Enable pretty-printing for gdb\",\n                    \"text\": \"-enable-pretty-printing\",\n                    \"ignoreFailures\": true\n                }\n            ]\n        },\n        {\n            \"name\": \"misra.py\",\n            \"type\": \"python\",\n            \"request\": \"launch\",\n            \"program\": \"${workspaceFolder}/addons/misra.py\",\n            \"console\": \"integratedTerminal\",\n            \"args\": [\n                \"${workspaceFolder}/addons/test/misra/misra-test.c.dump\"\n            ]\n        }\n    ]\n}\n```\n\n### Qt Creator + MinGW\n\nThe PCRE dll is needed to build the CLI. It can be downloaded here:\nhttp://software-download.name/pcre-library-windows/\n\n### GNU make\n\nSimple, unoptimized build (no dependencies):\n\n```shell\nmake\n```\n\nThe recommended release build is:\n\n```shell\nmake MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck HAVE_RULES=yes CXXFLAGS=\"-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function\"\n```\n\nFlags:\n\n1.  `MATCHCOMPILER=yes`\n    Python is used to optimise cppcheck. The Token::Match patterns are converted into C++ code at compile time.\n\n2.  `FILESDIR=/usr/share/cppcheck`\n    Specify folder where cppcheck files are installed (addons, cfg, platform)\n\n3.  `HAVE_RULES=yes`\n    Enable rules (PCRE is required if this is used)\n\n4.  `CXXFLAGS=\"-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function\"`\n    Enables most compiler optimizations, disables cppcheck-internal debugging code and enables basic compiler warnings.\n\n### g++ (for experts)\n\nIf you just want to build Cppcheck without dependencies then you can use this command:\n\n```shell\ng++ -o cppcheck -std=c++11 -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml2 -Iexternals/picojson -Ilib cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml2/*.cpp\n```\n\nIf you want to use `--rule` and `--rule-file` then dependencies are needed:\n\n```shell\ng++ -o cppcheck -std=c++11 -lpcre -DHAVE_RULES -Ilib -Iexternals -Iexternals/simplecpp -Iexternals/tinyxml2 cli/*.cpp lib/*.cpp externals/simplecpp/simplecpp.cpp externals/tinyxml2/*.cpp\n```\n\n### MinGW\n\n```shell\nmingw32-make\n```\n\nIf you encounter the following error with `MATCHCOMPILER=yes` you need to specify your Python interpreter via `PYTHON_INTERPRETER`.\n\n```\nprocess_begin: CreateProcess(NULL, which python3, ...) failed.\nmakefile:24: pipe: No error\nprocess_begin: CreateProcess(NULL, which python, ...) failed.\nmakefile:27: pipe: No error\nmakefile:30: *** Did not find a Python interpreter.  Stop.\n```\n\n### Other Compiler/IDE\n\n1. Create an empty project file / makefile.\n2. Add all cpp files in the cppcheck cli and lib folders to the project file / makefile.\n3. Add all cpp files in the externals folders to the project file / makefile.\n4. Compile.\n\n### Cross compiling Win32 (CLI) version of Cppcheck in Linux\n\n```shell\nsudo apt-get install mingw32\nmake CXX=i586-mingw32msvc-g++ LDFLAGS=\"-lshlwapi\" RDYNAMIC=\"\"\nmv cppcheck cppcheck.exe\n```\n\n## Packages\n\nBesides building yourself on the platform of your choice there are also several ways to obtain pre-built packages.\u003cbr/\u003e\n\nOfficial packages maintained by the Cppcheck team:\n- (Windows) An official Windows installer is available via the official Cppcheck SourceForge page: https://cppcheck.sourceforge.io.\n- (Windows) Official builds of the current development versions are available via the [release-windows](https://github.com/danmar/cppcheck/actions/workflows/release-windows.yml) workflow. They are built nightly for the `main` branch and for each commit for release branches. As these are development versions please refrain from using these in production environments!\n  - A portable package (i.e. does not require installation) is available as the `portable` artifact. This is still a work-in-progress - see https://trac.cppcheck.net/ticket/10771 for details.\n  - An installer is available via the `installer` artifact.\n- (Multi-Platform) A premium version with additional features provided by the original author of Cppcheck is available for purchase via https://www.cppcheck.com.\n\nUnofficial packages *not* maintained by the Cppcheck team but their respective packagers:\n- (Windows / Outdated) A portable package is available via https://portableapps.com/apps/development/cppcheck-portable.\n- (Windows / Outdated) A package is available via https://community.chocolatey.org/packages/cppcheck.\n- (Windows / Outdated) A package is available via https://winget.run/pkg/Cppcheck/Cppcheck.\n- (Windows / Outdated) A package is available via https://osdn.net/projects/sfnet_cppcheck.\n- (Windows) A package is available via https://scoop.sh/#/apps?q=cppcheck.\n- (Linux/Unix) Many major distros offer Cppcheck packages via their integrated package managers (`yum`, `apt`, `pacman`, etc.). See https://pkgs.org/search/?q=cppcheck or https://repology.org/project/cppcheck for an overview.\n- (Linux/Unix) Unless you are using a \"rolling\" distro, it is likely that they are not carrying the latest version. There are several external (mainly unsupported) repositories like AUR (ArchLinux), PPA (ubuntu), EPEL (CentOS/Fedora) etc. which might provide up-to-date packages. \n- (Linux/Unix / Outdated) The Canonical Snapcraft packages (https://snapcraft.io/cppcheck / https://snapcraft.io/cppcheckgui) are unmaintained and contain very old (development) versions. Please refrain from using them! See https://trac.cppcheck.net/ticket/11641 for more details.\n- (MacOS) A package is available via Homebrew (`brew`). See https://formulae.brew.sh/formula/cppcheck.\n- (MacOS) A package is available via https://ports.macports.org/port/cppcheck\n- (Multi-Platform) A package is available via https://anaconda.org/conda-forge/cppcheck.\n- Packages are also available from various download portals (mainly the Windows installer - sometimes re-packaged).\n\n*Note:* This is list is purely informational and listed in no particular order.\n\n*Note:* Please always try to obtain the package from the primary official source of your operating system/distro first and make sure you are getting the latest released version.\n\n*Note:* Some issues might be related to additional patches carried by the builds in these packages or the packaging itself. In that case issues might need to be reported to the respective project.\n\n## Webpage\n\nhttps://cppcheck.sourceforge.io/\n","funding_links":[],"categories":["TODO scan for Android support in followings","C++","Development Environment","Code Analysis","检测软件","Test Frameworks","Tools","Software / Web Service","Automation"],"sub_categories":["Lint and Format","UI Test Automation Scripting","Static \u0026 Dynamic Analysis","Development","Static Analysis Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanmar%2Fcppcheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanmar%2Fcppcheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanmar%2Fcppcheck/lists"}