libtraceevent: Fixing linking to C++ code
Linking in C++ compilers (including g++) causes references to be created
with their arguments. Due to this, trace library headers included into
C++ code base will cause their objects to built with symbols with
arguments. Apparently this is to support operator overloading in C++.
This causes linker errors. For example, here's what I get when I try to
link libtraceevent with a main.o built from a C++ main.cc source file.
main.cc:(.text+0x90):
undefined reference to `trace_seq_init(trace_seq*)'
undefined reference to `trace_seq_do_printf(trace_seq*)'
undefined reference to `tep_event_fields(tep_event*)'
The standard fix for this is to wrap the C project's header in
extern "C".
With this patch, I am able to link libtraceevent into a C++
code base.
Link: https://lore.kernel.org/linux-trace-devel/20220815031551.775444-1-joel@joelfernandes.org
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2 files changed