Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of C Cpp Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-c-cpp-knowledge-patch)
---
name: c-cpp-knowledge-patch
description: C and C++
version: null
license: MIT
metadata:
author: Nevaberry
---
# C and C++ compatibility
Load this skill for C and C++ compiler migration, language support, library
compatibility, diagnostics, target configuration, and offloading work.
Use the topic references for complete guidance and compiler-specific examples.
| Reference | Topics |
| --- | --- |
| [C language and standards](references/c-language-and-standards.md) | Dialects, declarations, generic selection, arrays, embedding, C extensions |
| [C++ language and modules](references/cpp-language-and-modules.md) | Initialization, lifetime, templates, structured bindings, modules, implementation limits |
| [Diagnostics and tooling](references/diagnostics-and-tooling.md) | Warning changes, SARIF, Static Analyzer, clang-format, tool APIs, Python bindings |
| [Libraries, builtins, and attributes](references/libraries-builtins-and-attributes.md) | Headers, library facilities, contracts, relocation, type queries, thread safety |
| [Migration and ABI](references/migration-and-abi.md) | Build defaults, dependencies, symbols, calling conventions, platform and library ABI |
| [Optimization, debugging, and sanitizers](references/optimization-debugging-and-sanitizers.md) | Pointer arithmetic, floating point, LTO, debug visibility, sanitizer controls |
| [Targets, offloading, and OpenMP](references/targets-offloading-and-openmp.md) | Arm, X86, LoongArch, RISC-V, WebAssembly, GPU drivers, OpenACC, OpenMP |
## Breaking changes and deprecations
### Build defaults and dependencies
GCC 16.1 defaults to `-std=gnu++20`. Set `-std=gnu++17` or `-std=c++17`
explicitly to stay on C++17. Older Autoconf scripts can add an unintended
`-std=gnu++11`; regenerate with Autoconf 2.73 or later to correct detection.
With Clang 22.1, link `clangOptions` for options APIs previously supplied by
`clangDriver`. Link `clangDriver` explicitly for driver APIs previously
obtained through `clangFrontend`.
libstdc++ exposes fewer declarations through indirect includes in GCC 15.1.
Add `<stdint.h>` for global fixed-width typedefs, `<cstdint>` for their `std`
forms, and `<ostream>` for `std::endl` and `std::flush`. Remove `<cstdbool>`
and `<cstdalign>` from modern C++; replace `<ccomplex>` with `<complex>` and
`<ctgmath>` with `<cmath>` or `<complex>` as needed.
### Binary compatibility
For affected Clang C++ interfaces, the compatibility switch depends on the change:
| Change | Compatibility guidance |
| --- | --- |
| Clang 20.1 Itanium construction vtables and member-like friend templates | Use `-fclang-abi-compat=19` for old manglings. |
| Clang 20.1 MSVC 19.20+ `auto` and `decltype(auto)` return mangling | Use `-fms-compatibility-version=19.14` for the older spelling. |
| Clang 21.1 larger record returns moving from AVX registers to memory | Use `-fclang-abi-compat=20` across affected interfaces. |
| Clang 22.1 MSVC ABI `::delete` behavior | Use `-fclang-abi-compat=21` for the old behavior; rebuild binaries sharing classes whose virtual destructors use the changed vector deleting destructor symbol together. |
GCC 16.1 changes Solaris `int8_t`, `int_fast8_t`, and `int_least8_t` to
`signed char`. Rebuild affected C++ interfaces together; `_LEGACY_INT8_T`
temporarily preserves the old ABI when rebuilding together is not possible.
Check affected libstdc++ C++20 binary interfaces before mixing objects built
with different versions.
See the ABI reference for those interfaces and other target-specific changes.
### Diagnostics that now fail builds
Clang 20.1 rejects extraneous template heads by default; remove redundant
heads or use `-Wno-error=extraneous-template-head`. Clang 21.1 makes chained
comparisons and folds over a comparison operator errors by default. Write
`a < b && b < c` for a range test or use `-Wno-error=parentheses`.
Clang 22.1 makes `-Wincompatible-pointer-types` an error by default. Use
`-Wno-error=incompatible-pointer-types` to retain a warning during migration.
Its `--warning-suppression-mappings=` uses the last matching entry, so put
specific patterns after overlapping general patterns when they should win.
GCC 16.1's unqualified unused-but-set warnings select level 3. Level 2 ignores
increments and decrements; level 3 also ignores compound assignments whose
right-hand side leaves the previous value unread. Use
`-Wunused-but-set-variable=1` or `-Wunused-but-set-parameter=1` to approximate
the old behavior.
### Removed interfaces and diagnostic output
Clang 21.1 removes `-frelaxed-template-template-args`, its negative form,
and `__is_referenceable`. Clang 22.1 removes `trivially_relocable_if_eligible`,
`replaceable_if_eligible`, and `__builtin_is_replaceable`; it retains
`__builtin_is_cpp_trivially_relocatable` and `__builtin_trivially_relocate`
with P2786 semantics and no syntax to explicitly declare a type relocatable.
GCC 15.1 deprecates JSON diagnostic format; GCC 16.1 removes
`-fdiagnostics-format=json`. Switch machine-readable output and its consumers
to SARIF. `gcc -fdiagnostics-add-output=sarif -c input.c` adds SARIF alongside
text diagnostics; `-fdiagnostics-set-output=` provides finer output control.
### Target and offload migration
With Clang 22.1, replace width-suffixed AVX10 options and feature names with
unsuffixed forms and remove `evex512` requests. The driver also removed
`-mevex512` and `-mno-evex512`. Earlier releases differ; see the target reference
for their spellings. Use `--target=wasm32-wasip1`; `wasm32-wasi` warns by default.
Clang 20.1's default CUDA driver enables device LTO and `-fgpu-rdc` with
static libraries. Its RDC binaries are incompatible with those produced by
`nvcc`; select the old driver with `--no-offload-new-driver`.
### Language and initialization traps
In GCC 15.1, outside static-storage-duration initialization, union `{0}` can
leave padding uncleared. Use `{}` where valid or
`-fzero-init-padding-bits=unions` when padding must be zero.
Clang 22.1 gives a GNU statement expression type `void` if its final statement
is empty. Use `int value = ({ 1; });` rather than `({ 1;; })` for a value.
Clang 20 implements C++26's removal of direct array comparisons. Use
`std::ranges::equal(a, b)` for element-wise equality or
`std::data(a) == std::data(b)` for pointer equality.
## Optimization, debugging, and sanitizer controls
Clang can fold `ptr + unsigned_offset < ptr` to false. Check the offset against
available distance before forming the pointer, or use `uintptr_t` arithmetic
to check byte-address wraparound. In Clang 20.1, `-fwrapv` covers signed integer
overflow alone, `-fwrapv-pointer` covers pointer overflow, and
`-fno-strict-overflow` enables both.
Use Clang 20.1's `-ffp-model=aggressive` for the old `-ffp-model=fast` behavior.
The revised `fast` allows infinities and NaNs and uses promoted complex
division where possible. `-fveclib=ArmPL` and `-fveclib=SLEEF` enable
`-fno-math-errno`.
Clang 21.1's `-Og` automatically extends variable liveness. Both
`-gkey-instructions` and `-gno-key-instructions` imply `-g`.
Clang 22.1 defaults `-gkey-instructions` on when emitting DWARF for optimized
plain C or C++.
Starting with Clang 21.1, use `-fsanitize=undefined,vptr` to retain vptr checks
alongside the undefined-behavior group. Clang 22.1's trapping UBSan emits
detailed trap reasons in debug info by default. Optimized builds can merge
traps and lose individual reasons; disable merging for relevant checks with
`-fno-sanitize-merge=` to preserve them.
## Language and library quick reference
### C dialect selection and implementation limits
Clang 18 first supports both `-std=c23` and inferred object declarations such
as `auto count = 3;`. Older releases provide `-std=c2x`. Clang 19 adds C23
`constexpr` objects and `#embed`, and supports `-std=c2y`.
C2y named loops require Clang 22; initializer declarations in `if` require
Clang 24. Clang's C2y implementation lacks N3348 multidimensional-array
matching, N3517 decay-free subscripting, and N3715 expression-form
`static_assert`. GCC 16.1's C2Y mode supports static assertions in expressions
and unspecified-bound or variably modified arrays in `_Generic` associations.
Clang 22.1's `-fdefer-ts` enables the draft C `defer` facility from WG14 N3734.
Its specification can still change.
### C++ implementation limits
Use Clang's `-std=c++2d` for draft C++29 mode. Clang's C++2c support lacks
reflection and contracts. GCC 16.1 provides reflection and splicing with
`-std=c++26 -freflection`; its C++26 implementation also includes contracts,
expansion statements, structured-binding packs, `constexpr` exceptions and
virtual inheritance, and erroneous behavior for uninitialized reads.
GCC's `constexpr` structured-binding support is partial.
Clang 20 extends temporaries in C++23 range initializers. For
`for (int x : make_owner().items())`, the temporary owner stays alive if
`items()` returns a reference to its member. On older versions, put the owner
in the loop's init-statement.
Clang lacks C++23 deduction from inherited constructors; supply explicit
template arguments or a deduction guide for the derived class. Clang 19
begins alias-template deduction support while `__cpp_deduction_guides` still
reports the older level; use a compile probe for the needed alias form.
### Modules and library facilities
Clang 22.1 defaults to reduced BMIs. Check that two-phase module builds support
them when compiling interfaces to object files. Clang's C++20 modules implement
only part of P1815R2: keep translation-unit-local entities out of exported
interfaces and check the importing translation unit when adopting modules.
With GCC 16.1's experimental C++20 modules enabled,
`g++ -std=c++20 -fmodules --compile-std-module -c main.cc` builds the
`<bits/stdc++.h>` header unit and the `std` and `std.compat` modules before
compiling `main.cc`.
GCC 16.1's libstdc++ adds `std::mdspan` and `allocate_at_least` for C++23. Its C++26
additions include `std::simd`, `std::inplace_vector`, `std::optional<T&>`, and
`std::function_ref`. See the library reference for the complete facility list.
### Lifetime and counted-storage annotations
Apply `[[clang::lifetimebound]]` to a named parameter. Clang 20.1 rejects it on
a type, on parameters of a `void`-returning function, and in the member-function
position on an explicit-object member function. `[[clang::lifetime_capture_by(out)]]`
describes another parameter that can retain a reference to the argument.
Clang 20.1's `__builtin_counted_by_ref` takes a flexible-array member expression
and returns a pointer to its `counted_by` field. Set the count before accessing
the array; use `_Generic` in macros for the unannotated member's `void *` result.
GCC 16.1 also supports `counted_by` on pointer members to associate an element
count with another structure member.