I have a kernel project with C files, C libraries and C++ libraries as well.
When the project is built such that the main file (.c) has a reference to any function in one of those C++ libraries, the running system is damaged somehow, that is one of the tasks gets the CPU to 100% and never gives it up again.
All tasks are healthy (no HALTED, no SUSPENDED, no EXCEPTION) but that task blocks the overall system by allocating CPU.
That C++ library function is correctly called, can be debugged by breakpoints etc.
It seems that a side effect occurs when it is linked.
The problem is observed even if that C++ library function is just referenced, not even called.
There is no such a problem when using other C++ libraries.
How can you explain this and what points should I focus on?
Are your C++ libraries declaring their functions with the
extern "C"construct? See this faq:(32.6) How can I create a C++ function f(int,char,float) that is callable by my C code?
If you want the same C API header file to be usable by both C and C++, you can use the following commonplace trick:
There is no C++ runtime support in the kernel. Things like
new,delete, and exceptions will not work. See this blog article for tips on porting C++ code to the kernel.