SerialPort 1.0beta
|
debug-msg.h文件参考
Some macros(debug, error handle) usually used in my programs. 更多...
#include <stdio.h>
#include <string.h>
#include <errno.h>
宏定义 | |
#define | error_exit(error) |
A macro that prints the error msg and exit. | |
#define | error_ret(error) |
A macro that prints the error msg and return -1. | |
#define | unix_error_exit(error) |
A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'. | |
#define | unix_error_ret(error) |
A macro that prints the error msg(with errno) and then return -1. I put 'unix' before the 'function' name because I am using 'errno'. | |
#define | unix_print_error(error) |
A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'. This error handle(detail version) can show the file , function and line where the error happens. | |
#define | DEBUG 1 |
#define | debug_msg(fmt,...) fprintf(stdout, fmt, ##__VA_ARGS__) |
A macro that prints the debug msg, as the same with printf. | |
#define | TRACE 1 |
#define | debug_trace(trace) |
A macro that traces the file , function and line . |
详细描述
Some macros(debug, error handle) usually used in my programs.
Copyleft (C) 2010 Late Lee This program is tested on LINUX PLATFORM, WITH GCC 4.x. The program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. Please feel free to use the program, and I feel free to ignore the related issues. Any questions or suggestions, or bugs, please contact me at $ echo -n "aHR0cDovL3d3dy5sYXRlbGVlLm9yZwo=" | base64 -d or e-mail to $ echo -n "bGF0ZWxlZUAxNjMuY29tCg==" | base64 -d if you want to do this.
- 日期:
- 2010
- 测试:
- I only use this file on linux(with x86 & arm) platform.
宏定义文档
#define DEBUG 1 |
we debug all the time
#define debug_trace | ( | trace | ) |
fprintf(stdout, "%s File:%s Line:%d Func:%s.\n", \
trace, __FILE__, __LINE__, __func__)
A macro that traces the file
, function
and line
.
#define error_exit | ( | error | ) |
do{ \ fprintf(stderr, "%s\n", error); \ exit(0); \ } while(0)
A macro that prints the error msg and exit.
#define error_ret | ( | error | ) |
do{ \ fprintf(stderr, "%s\n", error); \ return -1; \ } while(0)
A macro that prints the error msg and return -1.
#define TRACE 1 |
we trace all the time
#define unix_error_exit | ( | error | ) |
do{ \ fprintf(stderr, "%s Info[%d]:%s\n", \ error, errno, strerror(errno)); \ exit(1); \ } while(0)
A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'.
#define unix_error_ret | ( | error | ) |
do{ \ fprintf(stderr, "%s Info[%d]:%s\n", \ error, errno, strerror(errno)); \ return -1; \ } while(0)
A macro that prints the error msg(with errno) and then return -1. I put 'unix' before the 'function' name because I am using 'errno'.
#define unix_print_error | ( | error | ) |
do { \ fprintf(stderr, "Oh God!\nFile:%s Line:%d Function:%s:\n", \ __FILE__, __LINE__, __func__); \ perror(error); \ exit(0); \ } while(0)
A macro that prints the error msg(with errno) and then exit. I put 'unix' before the 'function' name because I am using 'errno'. This error handle(detail version) can show the file
, function
and line
where the error happens.
- 注解:
- I do not often use this 'function' in my program.
Generated at 2011年一月17日 星期一 10:44:34 for SerialPort by
