C ++ 2个基于Eclipse的IDE,1个捕获异常,另一个不捕获异常

时间:2018-07-11 21:59:18

标签: c++ eclipse

我现在有点卡住了。 我最近一直在从事C ++项目,但遇到异常时遇到麻烦。 目标是STM32。 我使用STs Cube MX代码生成器设置了2个项目。 执行的代码是

try
    {
        throw 1;
    }
    catch(const int& ex)
    {
        configASSERT(0);
    }

我使用过的IDE(SW4STM32,基于eclipse,g ++)无法捕获该异常。我总是遇到终止处理程序。另一个IDE(atolic true studio,基于eclipse的g ++)捕获了异常。

因此,这不是目标问题,而是IDE问题。我已经从g ++编译器和链接器选项中删除了fno-exceptions。但是仍然没有运气。 您对其他地方还有其他想法吗?

Thx:)

编辑: SW4STM32编译器标志(控制台输出)

22:40:11 **** Incremental Build of configuration Debug for project Test_Exceptions_AC6 ****
make -j4 all 
Building file: ../Core/Src/User/Test/Test.cpp
Invoking: MCU G++ Compiler
Test_Exceptions_AC6\Debug
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 '-D__weak=__attribute__((weak))' '-D__packed=__attribute__((__packed__))' -DUSE_HAL_DRIVER -DSTM32F429xx -I"xxx/Test_Exceptions_AC6/Core/Inc" -I"xxx/Test_Exceptions_AC6/Core/Inc/User" -I"xxx/Test_Exceptions_AC6/Drivers/STM32F4xx_HAL_Driver/Inc" -I"xxx/Test_Exceptions_AC6/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy" -I"xxx/Test_Exceptions_AC6/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F" -I"xxx/Test_Exceptions_AC6/Drivers/CMSIS/Device/ST/STM32F4xx/Include" -I"xxx/Test_Exceptions_AC6/Middlewares/Third_Party/FreeRTOS/Source/include" -I"xxx/Test_Exceptions_AC6/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS" -I"xxx/Test_Exceptions_AC6/Drivers/CMSIS/Include"  -Og -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fno-rtti -MMD -MP -MF"Core/Src/User/Test/Test.d" -MT"Core/Src/User/Test/Test.o" -o "Core/Src/User/Test/Test.o" "../Core/Src/User/Test/Test.cpp"
../Core/Src/User/Test/Test.cpp: In function 'void Test_Func()':
../Core/Src/User/Test/Test.cpp:56:21: warning: unused variable 'n_elements' [-Wunused-variable]
   volatile uint32_t n_elements = test_custom_list.size();
                     ^~~~~~~~~~
Finished building: ../Core/Src/User/Test/Test.cpp

SW4STM32链接器输出

Building target: Test_Exceptions_AC6.elf
Invoking: MCU G++ Linker
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T"../STM32F429ZITx_FLASH.ld" -Wl,-Map=output.map -Wl,--gc-sections -fno-rtti -o "Test_Exceptions_AC6.elf" @"objects.list"   -lm
Finished building target: Test_Exceptions_AC6.elf

make --no-print-directory post-build
Generating hex and Printing size information:
arm-none-eabi-objcopy -O ihex "Test_Exceptions_AC6.elf" "Test_Exceptions_AC6.hex"
arm-none-eabi-size "Test_Exceptions_AC6.elf"
   text    data     bss     dec     hex filename

语音输出

   22:46:09 **** Incremental Build of configuration Debug for project Exceptions_True_Studio ****
Info: Internal Builder is used for build
arm-atollic-eabi-g++ -c ..\Core\Src\User\Test\Test.cpp -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c++14 -DSTM32F10X_MD -DSTM32F429xx -D__packed=__attribute__((__packed__)) -D__weak=__attribute__((weak)) -DUSE_STDPERIPH_DRIVER -I../Core/Inc/User -I../Core/Inc/ -I../Drivers/CMSIS/Include -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -I../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F4xx_HAL_Driver/Inc -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -O0 -ffunction-sections -g -fstack-usage -Wall -Wextra -Wfatal-errors -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -fno-threadsafe-statics -o Core\Src\User\Test\Test.o 
..\Core\Src\User\Test\Test.cpp: In function 'void Test_Func()':
..\Core\Src\User\Test\Test.cpp:47:21: warning: unused variable 'n_elements' [-Wunused-variable]
   volatile uint32_t n_elements = test_custom_list.size();
                     ^~~~~~~~~~
arm-atollic-eabi-g++ -o Exceptions_True_Studio.elf Core\Src\User\Test\Test.o Core\Src\crc.o Core\Src\dma2d.o Core\Src\fmc.o Core\Src\freertos.o Core\Src\gpio.o Core\Src\i2c.o Core\Src\ltdc.o Core\Src\main.o Core\Src\spi.o Core\Src\stm32f4xx_hal_msp.o Core\Src\stm32f4xx_hal_timebase_TIM.o Core\Src\stm32f4xx_it.o Core\Src\system_stm32f4xx.o Core\Src\tim.o Core\Src\usart.o Core\Src\usb_otg.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_crc.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma2d.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dsi.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_hcd.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_ltdc.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_ltdc_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_sdram.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_spi.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_fmc.o Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_usb.o Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS\cmsis_os.o Middlewares\Third_Party\FreeRTOS\Source\croutine.o Middlewares\Third_Party\FreeRTOS\Source\event_groups.o Middlewares\Third_Party\FreeRTOS\Source\list.o Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.o Middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.o Middlewares\Third_Party\FreeRTOS\Source\queue.o Middlewares\Third_Party\FreeRTOS\Source\tasks.o Middlewares\Third_Party\FreeRTOS\Source\timers.o startup\startup_stm32f429xx.o -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T../STM32F429ZI_FLASH.ld -specs=nosys.specs -static -Wl,-cref,-u,Reset_Handler, -Wl,-Map=Exceptions_True_Studio.map -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x1000 -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group 
C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.0.1\ide\jre\bin\java -jar C:\Program Files (x86)\Atollic\TrueSTUDIO for STM32 9.0.1\Tools\arm-atollic-reports.jar sizeinfo list Exceptions_True_Studio.elf 
Generate build reports...
Print size information
   text    data     bss     dec     hex filename
 307304    1924  173124  482352   75c30 Exceptions_True_Studio.elf
Print size information done
Generate listing file
Output sent to: Exceptions_True_Studio.list
Generate listing file done
Generate build reports done
arm-atollic-eabi-objcopy.exe -O ihex Exceptions_True_Studio.elf Exceptions_True_Studio.hex 
Info: Parallel threads used: 1

22:46:21 Build Finished (took 12s.140ms)

现在您可以看到,没有fnoexceptions处于活动状态。因此,我希望收到例外。 :(

SW4STM32使用Eclipse Platform 4.6.3 Eclipse CDT 9.2.1 Attolic使用Eclipse Platform 4.6.1,Eclipse CDT 9.1.0

因此eclipse基本版本非常相似。 您还有其他想法吗?

0 个答案:

没有答案
相关问题