You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When we include the header file subsys/tracing/include/tracing_cpu_stats.h
into the C++ file with reference to one of the functions it will not link.
To Reproduce
Steps to reproduce the behavior:
add C++ file into the Zephyr project
enable TRACING_CPU_STATS in menuconfig
#include "tracing_cpu_stats.h"
call on of the functions, e.g. cpu_stats_non_idle_and_sched_get_percent();
compile and see the error
Expected behavior
The project should compile and link.
Impact
The feature prevent from compiling the project.
Screenshots or console output
: app/libapp.a(cpu_detailed_stats.cpp.obj): in function saveData': /home/hid/aurora/aurora/app/src/cpu_stats/cpu_detailed_stats.cpp:169: undefined reference to cpu_stats_non_idle_and_sched_get_percent()'
/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/hid/aurora/aurora/app/src/cpu_stats/cpu_detailed_stats.cpp:171: undefined reference to `cpu_stats_reset_counters()'
collect2: error: ld returned 1 exit status
Environment (please complete the following information):
OS: Linux
Toolchain ninja
Version 2.2.0.0
Additional context
The fix is to add the following #ifdefs into the header file:
When tracing_cpu_stats.h is included by C++ file it will not compile
and link correctly due to missing #ifdef __cplusplus directives
in the header file.
Fixes#23072
Signed-off-by: Dariusz Lisik <dariusz.lisik@hidglobal.com>
hakehuang
pushed a commit
to hakehuang/zephyr
that referenced
this issue
Mar 18, 2020
When tracing_cpu_stats.h is included by C++ file it will not compile
and link correctly due to missing #ifdef __cplusplus directives
in the header file.
Fixeszephyrproject-rtos#23072
Signed-off-by: Dariusz Lisik <dariusz.lisik@hidglobal.com>
Describe the bug
When we include the header file subsys/tracing/include/tracing_cpu_stats.h
into the C++ file with reference to one of the functions it will not link.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The project should compile and link.
Impact
The feature prevent from compiling the project.
Screenshots or console output
: app/libapp.a(cpu_detailed_stats.cpp.obj): in function
saveData': /home/hid/aurora/aurora/app/src/cpu_stats/cpu_detailed_stats.cpp:169: undefined reference to
cpu_stats_non_idle_and_sched_get_percent()'/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: /home/hid/aurora/aurora/app/src/cpu_stats/cpu_detailed_stats.cpp:171: undefined reference to `cpu_stats_reset_counters()'
collect2: error: ld returned 1 exit status
Environment (please complete the following information):
Additional context
The fix is to add the following #ifdefs into the header file:
diff --git a/subsys/tracing/include/tracing_cpu_stats.h b/subsys/tracing/include/tracing_cpu_stats.h
index cacaad21e0..4c5c2d23a9 100644
--- a/subsys/tracing/include/tracing_cpu_stats.h
+++ b/subsys/tracing/include/tracing_cpu_stats.h
@@ -10,6 +10,10 @@
#include <kernel_structs.h>
#include <init.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct cpu_stats {
u64_t idle;
u64_t non_idle;
@@ -41,4 +45,8 @@ void cpu_stats_reset_counters(void);
#define sys_trace_void(id)
#define sys_trace_end_call(id)
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TRACE_CPU_STATS_H */
The text was updated successfully, but these errors were encountered: