Skip to content

Clang-format version mismatch: Ubuntu 24 uses 18.x, cpptools bundles 21.x → inconsistent formatting & config parse errors #14155

@SanjanaNingappa

Description

@SanjanaNingappa

Environment

  • Host OS: Linux
  • Dev environment: Ubuntu 24.04 (local / Docker )
  • VS Code: 1.108.1
  • C/C++ Extension: ms-vscode.cpptools 1.29.3
  • System clang-format: 18.1.3 (Ubuntu default)
  • Bundled clang-format: 21.1.4 (extension's LLVM/bin)

Bug Summary and Steps to Reproduce

Bug Summary:

The ms-vscode.cpptools extension’s bundled clang-format (21.1.4) supports newer .clang-format keys than the system clang-format on Ubuntu 24 (18.1.3).
If "C_Cpp.clang_format_path" is set to /usr/bin/clang-format, formatting can fail due to unsupported keys or give different results.

Steps to reproduce:

  1. On Ubuntu 24:
sudo apt install clang-format
  clang-format --version  # 18.1.3

2..clang-format:

 BasedOnStyle: LLVM
 SpaceAroundPointerQualifiers: After
  1. Open a C++ file and format in VS Code:

Without C_Cpp.clang_format_path → works (bundled 21.1.4).
With C_Cpp.clang_format_path": "/usr/bin/clang-format" → fails with:

#define test ((status_t (*)) addr_test)

See error
error: invalid configuration key 'SpaceAroundPointerQualifiers'

Expected behavior:
Ability to use the bundled clang-format (21.x) in Linux/Docker without having to upgrade the system version.

Actual Behavior

  • Bundled (21) and system (18) behave differently.
  • Keys supported by 21 break with 18.
  • Upgrading requires adding LLVM apt repo manually.

Configuration and Logs

{// Use workspace .clang-format style file for formatting
    "C_Cpp.clang_format_style": "file:${workspaceFolder}/.clang-format",
    "C_Cpp.formatting": "clangFormat",
    "C_Cpp.clang_format_fallbackStyle": "none",
    "C_Cpp.intelliSenseEngine": "default",
    "C_Cpp.enhancedColorization": "enabled",
    "C_Cpp.errorSquiggles": "enabled",
    "C_Cpp.autocompleteAddParentheses": true,
    "C_Cpp.workspaceParsingPriority": "medium",

    // Auto-format when saving
    "editor.formatOnSave": true,
    "editor.formatOnSaveMode": "file",

    // Default formatter for C/C++
    "[c]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
    },
    "[cpp]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
    },

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions