mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-26 15:54:18 +08:00
7c8dce4b16
When auto-generated BPF skeleton C code is included from C++ application, it triggers compilation error due to void * being implicitly casted to whatever target pointer type. This is supported by C, but not C++. To solve this problem, add explicit casts, where necessary. To ensure issues like this are captured going forward, add skeleton usage in test_cpp test. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20191226210253.3132060-1-andriin@fb.com
31 lines
560 B
C++
31 lines
560 B
C++
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
|
|
#include <iostream>
|
|
#include "libbpf.h"
|
|
#include "bpf.h"
|
|
#include "btf.h"
|
|
#include "test_core_extern.skel.h"
|
|
|
|
/* do nothing, just make sure we can link successfully */
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct test_core_extern *skel;
|
|
|
|
/* libbpf.h */
|
|
libbpf_set_print(NULL);
|
|
|
|
/* bpf.h */
|
|
bpf_prog_get_fd_by_id(0);
|
|
|
|
/* btf.h */
|
|
btf__new(NULL, 0);
|
|
|
|
/* BPF skeleton */
|
|
skel = test_core_extern__open_and_load();
|
|
test_core_extern__destroy(skel);
|
|
|
|
std::cout << "DONE!" << std::endl;
|
|
|
|
return 0;
|
|
}
|