奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

C語言

嵌入式c語言調試開關的技巧

時間:2024-10-21 04:43:28 C語言 我要投稿
  • 相關推薦

嵌入式c語言調試開關的技巧

  在調試程序時,經常會用到assert和printf之類的函數,我最近做的這個工程里就有幾百個assert,在你自認為程序已經沒有bug的時候,就要除去這些調試代碼,應為系統在正常運行時這些用于調試的信息是無用的,而且會占用時間和空間。怎么刪除呢,以下僅供參考!

  下面給出最簡單的一種方法:

  #define DEBUG

  #ifdef DEBUG

  #define PRINTF(x) printf x

  #else

  #define PRINTF(x)  ((void)0)

  #endif

  使用時,PRINTF(( "Hello World! " ));

  注意這里是兩個括號,一個會報錯的

  不使用時,直接將"#define DEBUG"屏蔽掉

  另外一個調試時常用的方法是assert,還是在一個頭文件里,這里用的是STM32函數庫的例子

  #ifdef DEBUG 1

  /************************************************************

  * Macro Name : assert_param

  * Description : The assert_param macro is used for function's parameters check.

  * It is used only if the library is compiled in DEBUG mode.

  * Input : - expr: If expr is false, it calls assert_failed function

  * which reports the name of the source file and the source

  * line number of the call that failed.

  * If expr is true, it returns no value.

  * Return : None

  ************************************************************/

  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((u8 *)__FILE__, __LINE__))

  /* Exported functions -------------------------------------*/

  void assert_failed(u8* file, u32 line);

  #else

  #define assert_param(expr) ((void)0)

  #endif/* DEBUG */

  //assert_failed此函數要自己定義

  #ifdef DEBUG

  /************************************************************

  * Function Name : assert_failed

  * Description : Reports the name of the source file and the source line number

  * where the assert_param error has occurred.

  * Input : - file: pointer to the source file name

  * - line: assert_param error line source number

  * Output : None

  * Return : None

  ************************************************************/

  void assert_failed(u8* file, u32 line)

  {

  /* User can add his own implementation to report the file name and line number,

  ex: printf("Wrong parameters value: file %s on line %d ", file, line) */

  /* Infinite loop */

  while (1){

  }

  }

  #endif

【嵌入式c語言調試開關的技巧】相關文章:

嵌入式C語言優化技巧10-27

C語言調試器是如何工作的10-06

嵌入式C語言編程小知識12-20

嵌入式C語言學習秘訣08-25

C語言自學入門技巧09-17

C語言左右法則的技巧10-03

C語言宏定義技巧09-03

嵌入式C語言性能優化方法10-22

關于C語言宏定義的技巧09-21

C語言高效編程的小技巧09-13

主站蜘蛛池模板: 襄樊市| 宁海县| 湘潭市| 屯留县| 海淀区| 武陟县| 土默特右旗| 商洛市| 台前县| 黄梅县| 勃利县| 蒙阴县| 监利县| 合江县| 称多县| 长葛市| 梧州市| 酒泉市| 绥阳县| 阿坝| 乡宁县| 瑞金市| 松桃| 青海省| 永春县| 怀化市| 砚山县| 晋宁县| 大兴区| 日喀则市| 灌南县| 桂东县| 永福县| 孟津县| 泰安市| 雅安市| 昭平县| 苏州市| 启东市| 安西县| 汝阳县|