This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Cannot breakpoint on UART0_IRQHandler with C++

Hello all,

I am using the examples/peripheral/uart project, which by default is set up as follows:

Language = C Dialect = C99 Language conformance = Standard with IAR extensions

I can breakpoint on UART0_IRQHandler.

However, if I switch this project as follows:

Language = C++ Dialect = Extended embedded C++ Language conformance = Standard with IAR extensions

I now find I can no longer set a breakpoint on UART0_IRQHandler.

Does anyone have any idea how I resolve this? The reason I care about this is I am developing a C++ application and have hit upon this problem, and have found I can reproduce it (more-or-less) using the example project mentioned above.

Regards, Richard.

Parents
  • The reason why it matters is because there are two versions of UART0_IRQHandler--the weak version in arm_startup_nrf51.s and the strong version in app_uart_fifo.c. The assembly file is assembled by the assembler and will produce C-style names (probably "UART0_IRQHandler"). The source file is compiled by the C++ compiler, and will produce C++-style names (probably "UART0_IRQHandler()"). Since the two are different, the C++ generated version will not replace the assembler version, which leaves you with the weakly-bound default interrupt handler. The linker, then, noticing that there are no references anywhere to "UART0_IRQHandler()", strips the symbol out as an unused function.

    You will need to extern "C" all interrupt handlers as well as anytime there is a transition between your C++ code and Nordic's C code.

Reply
  • The reason why it matters is because there are two versions of UART0_IRQHandler--the weak version in arm_startup_nrf51.s and the strong version in app_uart_fifo.c. The assembly file is assembled by the assembler and will produce C-style names (probably "UART0_IRQHandler"). The source file is compiled by the C++ compiler, and will produce C++-style names (probably "UART0_IRQHandler()"). Since the two are different, the C++ generated version will not replace the assembler version, which leaves you with the weakly-bound default interrupt handler. The linker, then, noticing that there are no references anywhere to "UART0_IRQHandler()", strips the symbol out as an unused function.

    You will need to extern "C" all interrupt handlers as well as anytime there is a transition between your C++ code and Nordic's C code.

Children
No Data
Related