This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TM4C123GH6PM:对中断处理程序 C++项目的未定义引用

Guru**** 2522940 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1276983/tm4c123gh6pm-undefined-reference-to-interrupt-handler-c-project

器件型号:TM4C123GH6PM

大家好!

我正在使用 TM4C123系列 MCU 处理 C++项目、但在链接过程中收到了对我的中断处理程序的未定义引用。  `S的错误如下:(.isr_vector+0x3c):未定义对"sysTickIntHandler"的引用

由于我有一个 C++项目、所以我假设我在某处缺少 extern "C"{}、但这就是我到目前为止拥有的项目。 第一个是启动文件(startup_gcc.c)的一个片段

extern void SysTickIntHandler();

//*****************************************************************************
//
// The entry point for the application.
//
//*****************************************************************************
extern int main(void);

//*****************************************************************************
//
// Reserve space for the system stack.
//
//*****************************************************************************
static uint32_t pui32Stack[128];

//*****************************************************************************
//
// The vector table.  Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000.
//
//*****************************************************************************
__attribute__((section(".isr_vector"))) void (*const g_pfnVectors[])(void) = {
    (void (*)(void))((uint32_t)pui32Stack + sizeof(pui32Stack)),
    // The initial stack pointer
    ResetISR,           // The reset handler
    NmiSR,              // The NMI handler
    FaultISR,           // The hard fault handler
    IntDefaultHandler,  // The MPU fault handler
    IntDefaultHandler,  // The bus fault handler
    IntDefaultHandler,  // The usage fault handler
    0,                  // Reserved
    0,                  // Reserved
    0,                  // Reserved
    0,                  // Reserved
    IntDefaultHandler,  // SVCall handler
    IntDefaultHandler,  // Debug monitor handler
    0,                  // Reserved
    IntDefaultHandler,  // The PendSV handler
    SysTickIntHandler,  // The SysTick handler

以下是我如何声明中断处理程序

#ifdef __cplusplus
extern "C" {
#endif
void SysTickIntHandler() { system_counter++; }
#ifdef __cplusplus
}
#endif

我已经尝试过的方法:
1.重命名扩展名为.cpp 的启动文件

2.中断处理程序上的 extern "C"{}。

我跟踪过几个有类似问题的帖子、但他们说 extern "C"{}修复了它们、但我仍然收到链接错误。 我确定这是件愚蠢的事情。

非常感谢任何帮助,谢谢!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    找到了我的问题,我只是愚蠢,我忘了添加.cpp 文件,那里的 SysTick 驱动程序的东西是在我的 CMakelists.txt