Serial Port 1.0 beta
|
debug-msg.h File Reference
Some macros(debug, error handle) usually used in my programs. More...
#include <stdio.h>
#include <string.h>
#include <errno.h>
Go to the source code of this file.
Defines | |
#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 . |
Detailed Description
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.
- Date:
- 2010
- Test:
- I only use this file on linux(with x86 & arm) platform.
Define Documentation
#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.
- Note:
- I do not often use this 'function' in my program.
Generated on Tue Jan 18 2011 13:43:21 for Serial Port by
