Request a PoCDownload
Product

Platform

All features32 capabilities, from IDE to CICompliance KitsISO 26262, DO-178C, IEC 62304...AI GovernanceControl AI-generated C/C++ codeWhat’s new in 2026Latest version highlightsScreenshotsSee the product in action

Analyze & improve

Coding standardsMISRA, CERT, CWE, AUTOSARArchitecture & dependenciesGraphs, matrix, cyclesTechnical debtMeasured in hours and dollarsQuality gatesStop regressions in CISmart Code CityYour codebase in 3D

Integrations

IDE pluginsVisual Studio, VS Code, CLion...CI/CD pipelinesJenkins, Azure DevOps, GitHub, GitLabSonarQube pluginC/C++ results in SonarQubeExternal analyzersClang-Tidy, Cppcheck, coverageFeature on Demand
Solutions

By need

Functional safetyCompliance kits per standardCoding standardsMISRA, CERT, AUTOSAR, ISO...Legacy modernizationRefactor large C/C++ safelyCode auditExpert review of your codebaseM&A due diligenceAssess technical health fast

By role

DevelopersSoftware architectsTech leadsDevOps engineersEngineering managersProject managers

CTOsCIOs / IT leadersQA engineersSecurity leadersComplianceConsultantsRequest a guided PoC
Industries

Safety-critical

AutomotiveISO 26262, MISRA, AUTOSARAerospace & DefenseDO-178C programsMedical DevicesIEC 62304 softwareEnergy & UtilitiesIEC 61508 systemsEmbedded SystemsFirmware and devices

Enterprise

Financial ServicesTrading and paymentsGame DevelopmentEngines and large C++Software VendorsCommercial C/C++ productsGovernmentAgencies and contractorsAll industries & case studies
Resources

Learn

DocumentationGuides, rules and CI setupKnowledge baseFrequently asked questionsBlogC and C++ code quality articlesRelease notesEvery version since 2009

Customers

Case studiesSuccess storiesTestimonialsWhat users sayOur customersCompanies using CppDependGold Code QualityOpen source projects we rate

Programs & company

Feature on DemandMissing features built for freeFree for open sourceLicenses for OSS and studentsContact usSales and supportEULALicense agreement
DocsPricing
Documentation

Code Diff

Code Diff in CppDepend

Mastering Source Code Differences with CppDepend

This document explains how to use the CppDepend build comparison features, in the context of the interactive UI. The document Reporting Code Diff explains how to use the CppDepend build comparison features, in the context of reporting.

Getting Started Video (2:30 min)

Watch the Getting Started Video (2:30 min)

Learn how to use CppDepend's code diff features.

Introduction

Code evolution and code maintenance are some of the most prominent characteristics of software engineering.

CppDepend comes with some advanced code evolution and code diff features since mid 2009. One of the coolest results of CppDepend integrated in Visual Studio, is that now, developer benefit from several fine-grained code diff features, one click away from their natural developing environment. Let's expose 3 typical code diff scenarios.

Code Diff from within VisualCppDepend

So for example one can right-click a project in the Code Browser and ask for Select Methods (of the project) where Code was Changed.

CppDepend Class Browser

This will result in a CQLinq query generated that Select Methods (of the project) where Code was Changed. Naturally, for each method listed, one can jump straight to source code declaration or ask for diff.

CQLinq Query

Code Change Review through Search Panel

The Search Change Panel is actually just a CQLinq query generator related to Code change. For example, in the screenshot below, we can see that asking for Method + Change + Code was Changed or was Added generates the CQLinq query:

from m in Application.Methods

where m.CodeWasChanged() || m.WasAdded()

select new { m, m.NbLinesOfCode }

The result shown is ideal to do efficient Code Change Review: not only all code changes are nicely organized at a glance, but for each methods refactored, the developer is just one click away to observe diff in source files.

Code was changed

The Search Change Panel's options offers various possibilities to explore diff, including searching for code elements where code and only code (not comment) was changed or where comment and only comment was changed, where visibility was changed, where was added or removed etc...

A bonus option is to search diff in tier code, like asking for which library types is not used anymore for example.

Typically, developers like to write tests for testing automatically refactored and new code. Another cool bonus option is to search for diff coupled with code coverage by tests ratio, like asking for methods where code was changed (i.e refactored methods) and where it is not actually properly covered by tests.

Code Diff from within Visual Studio

As we just saw, there is an CppDepend menu in source code right-click menu, but there is also an CppDepend menu in Visual Studio source code editor. Since CppDepend recognizes the code element currently edited in source, the user can, for instance, right click a method and see if it has been changed. If the method code has indeed been changed, several options appear on the right click CppDepend menu. One of the option is Compare Older and Newer version of source file, which leads to opening a diff textual application to see changes

Code Diff within Visual Studio

Here is for example, the VS 2012 extension diff tool opened from clicking Compare Older and newer version of source file on the NUnit v2.4.8 vs. v2.5.3 method IsPlatformSupported().

VS 2012 Extension Diff Tool

Look back in the first screenshot above, and you'll see several other interesting options, including Open my declaration in older source code.

Let's precise that not only method changes are taken account but namespace, type and field changes as well. For example, one can right click a namespace source code declaration and ask for types or methods of the namespace that has been refactored or added.

At this point you might wonder how CppDepend/Visual Studio knows about the previous version of the code to compare against to (what is called the Baseline for Comparison). This concept is explained later in this article, let's jump to the second code diff scenario.

Defining the Baseline for Comparison

Earlier in the post we introduced the concept of Baseline for Comparison. This represents the previous snapshot version of the code base against which, the comparison is done. Typically, the Baseline for Comparison represents the latest version of the code in production.

The Baseline for Comparison can be specified through the menu: Diff > Define The Two Snapshots to Diff > Define the project's Baseline for Comparison. The dialog below appears and let chooses through different options to define the baseline. The Baseline for Comparison option is then persisted in the CppDepend project file.

Baseline Comparison Settings

Finally, any diff tools can be plugged through the menu Diff > Source Files Compare Tools.

Was this page helpful?Give feedbackRequest a feature