Skip to content

Using C++ std::exceptions #40278

Answered by ibboliver
ibboliver asked this question in Q&A
Discussion options

You must be logged in to vote

For those that might run into the same issue, here's my solution, inspired by https://community.infineon.com/t5/DAVE/Undefined-reference-to-fini/m-p/302777/highlight/true#M2150

I set the C++ and exceptions related config stuff:

CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y

CONFIG_NEWLIB_LIBC=y
CONFIG_EXCEPTIONS=y
CONFIG_NEWLIB_LIBC_NANO=n

To prevent the linker error, I implemented exit() by myself :

void exit(int reason) {
  printf("EXIT %d", reason);
  while (1)
    ;
}

Now the code compiles without error and the handled exceptions are being catched. Unhandled exceptions are running into exit().

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ibboliver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant