-DDEBUG编译标记

想必大家都有利用输出函数如printf来帮助我们调试程序的经历,这是一种比较原始的程序调试辅助方法,在Linux下也可以为我们所用。不过这种方法有一个明显的缺点,就是在调试完后我们必须注释或删除掉这些辅助代码。Linux C提供了-DDEBUG这个编译标记来定义DEBUG这个符号,借助于该符号,我们可以在应用程序中添加额外代码并根据需要决定执行与否。
如:
#include<stdio.h>
//*******dtest.c*******

int main()
{
#ifdef DEBUG
      printf("Debug output....../n");
#endif

printf("Main function ended!/n";
}

运行:
$ cc -o dtest dtest.c
$ ./dtest
Main function ended!
$ rm dtest
$ cc -o dtest  -DDEBUG dtest.c
$ ./dtest
Debug output......
Main function ended!

通过以上示例,你应该明白了-DDEBUG标记的用法了吧


转自:http://blog.youkuaiyun.com/junlixxu/article/details/5157960

07:39:05 **** 项目czhidao配置Debug的增量构建 **** make -j16 all arm-none-eabi-gcc "../Core/Src/dma_tim_config.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/dma_tim_config.d" -MT"Core/Src/dma_tim_config.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/dma_tim_config.o" arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/main.o" arm-none-eabi-gcc "../Core/Src/ws2812.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/ws2812.d" -MT"Core/Src/ws2812.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/ws2812.o" In file included from ../Core/Src/main.c:21: ../Core/Src/main.c: In function 'Generate_WS2812_Data': ../Core/Inc/ws2812.h:14:28: error: 'WS2812_BIT_1_PULS' undeclared (first use in this function); did you mean 'WS2812_BIT_1_PULSE'? 14 | #define WS2812_CCR_HIGH WS2812_BIT_1_PULS | ^~~~~~~~~~~~~~~~~ ../Core/Src/main.c:75:27: note: in expansion of macro 'WS2812_CCR_HIGH' 75 | *buffer++ = bit_val ? WS2812_CCR_HIGH : WS2812_CCR_LOW; | ^~~~~~~~~~~~~~~ ../Core/Inc/ws2812.h:14:28: note: each undeclared identifier is reported only once for each function it appears in 14 | #define WS2812_CCR_HIGH WS2812_BIT_1_PULS | ^~~~~~~~~~~~~~~~~ ../Core/Src/main.c:75:27: note: in expansion of macro 'WS2812_CCR_HIGH' 75 | *buffer++ = bit_val ? WS2812_CCR_HIGH : WS2812_CCR_LOW; | ^~~~~~~~~~~~~~~ ../Core/Src/main.c: In function 'main': ../Core/Src/main.c:91:5: warning: implicit declaration of function 'TIM2_DMA_Init'; did you mean 'MX_DMA_Init'? [-Wimplicit-function-declaration] 91 | TIM2_DMA_Init(); | ^~~~~~~~~~~~~ | MX_DMA_Init ../Core/Src/ws2812.c: In function 'Start_TIM2_DMA_Transfer': ../Core/Src/ws2812.c:54:9: error: 'BUFFER_SIZE' undeclared (first use in this function) 54 | BUFFER_SIZE | ^~~~~~~~~~~ ../Core/Src/ws2812.c:54:9: note: each undeclared identifier is reported only once for each function it appears in ../Core/Src/main.c:93:25: error: 'BUFFER_SIZE' undeclared (first use in this function) 93 | uint16_t led_buffer[BUFFER_SIZE]; | ^~~~~~~~~~~ In file included from ../Core/Src/ws2812.c:1: ../Core/Src/ws2812.c: In function 'Generate_WS2812_Data': ../Core/Inc/ws2812.h:14:28: error: 'WS2812_BIT_1_PULS' undeclared (first use in this function); did you mean 'WS2812_BIT_1_PULSE'? 14 | #define WS2812_CCR_HIGH WS2812_BIT_1_PULS | ^~~~~~~~~~~~~~~~~ ../Core/Src/ws2812.c:74:40: note: in expansion of macro 'WS2812_CCR_HIGH' 74 | *buffer++ = (grb & (1 << i)) ? WS2812_CCR_HIGH : WS2812_CCR_LOW; | ^~~~~~~~~~~~~~~ make: *** [Core/Src/subdir.mk:40: Core/Src/ws2812.o] Error 1 make: *** Waiting for unfinished jobs.... ../Core/Src/main.c:97:9: warning: implicit declaration of function 'Start_TIM2_DMA_Transfer' [-Wimplicit-function-declaration] 97 | Start_TIM2_DMA_Transfer(led_buffer); | ^~~~~~~~~~~~~~~~~~~~~~~ ../Core/Src/main.c:99:16: error: 'dma_transfer_complete' undeclared (first use in this function) 99 | while(!dma_transfer_complete); // 等待传输完成 | ^~~~~~~~~~~~~~~~~~~~~ ../Core/Src/main.c:93:14: warning: unused variable 'led_buffer' [-Wunused-variable] 93 | uint16_t led_buffer[BUFFER_SIZE]; | ^~~~~~~~~~ make: *** [Core/Src/subdir.mk:40: Core/Src/main.o] Error 1 "make -j16 all"以退出代码2结尾。构建可能不完整。 07:39:05 构建失败。 8 错误,3 警告。 (使用675ms) 再次报错请继续给出完整文件
06-13
09:18:14 **** Incremental Build of configuration Debug for project ov2640_AI **** make -j20 all arm-none-eabi-gcc "../Core/Src/main.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F103xB -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Core/Src/main.d" -MT"Core/Src/main.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/main.o" arm-none-eabi-gcc -o "ov2640_AI.elf" @"objects.list" -mcpu=cortex-m3 -T"C:\Users\l\STM32CubeIDE\workspace_1.19.0\ov2640_AI\STM32F103C8TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="ov2640_AI.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group C:/ST/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ov2640_AI.elf section `.bss' will not fit in region `RAM' C:/ST/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: region `RAM' overflowed by 57984 bytes collect2.exe: error: ld returned 1 exit status make: *** [makefile:64: ov2640_AI.elf] Error 1 "make -j20 all" terminated with exit code 2. Build might be incomplete. 09:18:14 Build Failed. 3 errors, 0 warnings. (took 338ms)
最新发布
07-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值