Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Software debugging: using assertion ASSERT macro positioning software bug

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

/ * * Author: DavidLin * Date: 2014-12-26pm * Email: linpeng1577@163.com or linpeng1577@gmail.com * world: the city of SZ In China * Ver: 000.000.001 * For: threads for rxtx! * history: editor time do * 1) LinPeng 2014-12-26 created this file! * 2) * / * assert_self.h * / # ifndef _ _ ASSERT _ SELF_H__#define _ _ ASSERT_SELF_H__#include#define ASSERT_ENABLE (1) # define xprintf printf / * xprintf can be tty print or uart print Etc * / # if ASSERT_ENABLE#define assert_error ()\ do\ {\ xprintf ("[ERROR] Assert FILE:% s: LINE% d\ n", _ _ FILE__, _ _ LINE__) \} while (0) # define ASSERT1 (para)\ do\ {\ if (! para)\ {\ assert_error ();\} while (0)\ # else / * if! ASSERT_ENABLE * / # define ASSERT1 (para)\ do\ {\ if (para)\ {\} while (0) # endif / * end of ASSERT_ENABLE * / # endif / * end of _ _ ASSERT_SELF_H__*/

Test case

/ * test case: test.c * / # include#include "assert_self.h" int main (int argc, char* argv []) {switch (argc) {case 2: ASSERT1 (atoi (argv [1])); break; default: printf ("ARG ACCEPT 1\ n"); break;} exit (0);}

Software Bug positioning, in many cases, such as the use of Assert macros, you can compress the 48-hour debugging meal into a dessert that can be eaten, each software team is re-evolving, the past experience is not always a good inheritance, this is us!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report