Skip to content

vmlinux.h is not valid C++ #2

Closed

Description

@maxskokov

vmlinux.h generated by bpftool btf dump file /sys/kernel/btf/vmlinux format c does not compile as C++: 162 errors on a bpf-next kernel. Causes:

  • C++ keywords used as names: private (45), new (11), delete (6), bool (6), class (5, including struct class), export (4), xor, template, virtual, not, namespace
  • typedef _Bool bool;
  • a tag and a typedef with the same name but different types (e.g. the e1000_* enums)
  • forward declarations of enums without an underlying type
  • type definitions inside anonymous structs and unions

Renaming the offending fields in the header is not enough on its own: libbpf matches field names in CO-RE relocations exactly (bpf_core_match_member() in relo_core.c); the ___flavor suffix is ignored only for type and enum value names.

This needs discussion on the BPF mailing list before any patch, likely a C++ mode for bpftool's C dumper together with a way for CO-RE to match renamed fields.

Activity

  1. added
    area/bpf
    upstream
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/bpfupstream

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions