summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorWanLi Niu <niuwl1@chinatelecom.cn>2026-01-06 10:31:23 +0800
committerAndrii Nakryiko <andrii@kernel.org>2026-01-09 11:01:54 -0800
commit4effccde0a0521b220c3585c9a0d8e677d345209 (patch)
treef0665576bd9d18ce780f5523b13e48218d56b0ef /kernel
parent2175ccfb93fd91d0ece74684eb7ab9443de806ec (diff)
bpftool: Make skeleton C++ compatible with explicit casts
Fix C++ compilation errors in generated skeleton by adding explicit pointer casts and use char * subtraction for offset calculation error: invalid conversion from 'void*' to '<obj_name>*' [-fpermissive] | skel = skel_alloc(sizeof(*skel)); | ~~~~~~~~~~^~~~~~~~~~~~~~~ | | | void* error: arithmetic on pointers to void | skel->ctx.sz = (void *)&skel->links - (void *)skel; | ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ error: assigning to 'struct <obj_name>__<ident> *' from incompatible type 'void *' | skel-><ident> = skel_prep_map_data((void *)data, 4096, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | sizeof(data) - 1); | ~~~~~~~~~~~~~~~~~ error: assigning to 'struct <obj_name>__<ident> *' from incompatible type 'void *' | skel-><ident> = skel_finalize_map_data(&skel->maps.<ident>.initial_value, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 4096, PROT_READ | PROT_WRITE, skel->maps.<ident>.map_fd); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Minimum reproducer: $ cat test.bpf.c int val; // placed in .bss section #include "vmlinux.h" #include <bpf/bpf_helpers.h> SEC("raw_tracepoint/sched_wakeup_new") int handle(void *ctx) { return 0; } $ cat test.cpp #include <cerrno> extern "C" { #include "test.bpf.skel.h" } $ bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h $ clang -g -O2 -target bpf -c test.bpf.c -o test.bpf.o $ bpftool gen skeleton test.bpf.o -L > test.bpf.skel.h $ g++ -c test.cpp -I. Co-developed-by: Menglong Dong <dongml2@chinatelecom.cn> Signed-off-by: WanLi Niu <niuwl1@chinatelecom.cn> Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20260106023123.2928-1-kiraskyler@163.com
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions