Hello World as C++ project

Hello,

after some hours extensive search, I want to share my findings.

I got very strange reset behaviours in a C++ project on an nRF5340 with nRF Connect SDK 2.1.0.

After stripping down the code, I reproduced the behaviour with the hello_world example. I changed it to C++ and added the function printTest2. 

#include <zephyr/zephyr.h>

bool printTest2() {
	printk("Test2\n");
}


int main(void)
{
	for (;;) {
		printk("Test1\n");
		printTest2();
		k_msleep(500);
	}
	return 0;
}

I know it should return a bool, but actually it does not return anything.

If the project is a pure C-project, it works without problems. 

But if it is C++, the result is as follows:

�*** Booting Zephyr OS build v3.1.99-ncs1 ***
Test1
�*** Booting Zephyr OS build v3.1.99-ncs1 ***
Test1
�*** Booting Zephyr OS build v3.1.99-ncs1 ***
Test1

I would be very thankful if someone could give me an advice why leaving the return away leads to a hard fault.

Many thanks in advance.

Kind regards,

Christian

Parents Reply Children
No Data
Related