代码拉取完成,页面将自动刷新
/**
* @file debug-msg.h
* @brief
* @author rendong (rendong@littt.com)
* @version 1.0
* @date 2020-08-25
*
* @copyright Copyright (c) 2020 成都科鸿凌泰自动识别
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2020-08-25 <td>1.0 <td>rendong <td>内容
* </table>
*/
#ifndef _DEBUG_MSG_H
#define _DEBUG_MSG_H
#include <stdio.h> /* perror() */
#include <string.h> /* strerror() */
#include <errno.h> /* errno */
/***
* Print the error msg is one thing
* but print the msg is another!!
*/
/**
* @def error_exit
* @brief A macro that prints the @a error msg and exit.
*/
#define error_exit(error) \
do \
{ \
fprintf(stderr, "%s\n", error); \
exit(0); \
} while (0)
/**
* @def error_ret
* @brief A macro that prints the @a error msg and return -1.
*/
#define error_ret(error) \
do \
{ \
fprintf(stderr, "%s\n", error); \
return -1; \
} while (0)
/**
* @def unix_error_exit
* @brief A macro that prints the @a error msg(with errno) and then exit.
* I put 'unix' before the 'function' name because I am using 'errno'.
*/
#define unix_error_exit(error) \
do \
{ \
fprintf(stderr, "%s Info[%d]:%s\n", \
error, errno, strerror(errno)); \
exit(1); \
} while (0)
/**
* @def unix_error_ret
* @brief A macro that prints the @a error msg(with errno) and then return -1.
* 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)
/* error handle ,detail version */
/* it can show the file,function and the line */
/**
* @def unix_print_error
* @brief A macro that prints the @a error msg(with errno) and then exit.
* I put 'unix' before the 'function' name because I am using 'errno'.@n
* This error handle(detail version) can show the @p file, @p function
* and @p line where the @a error happens.
* @note I do not often use this 'function' in my program.
*/
#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)
/* DEBUG=0 will show nothing */
#ifndef DEBUG
#define DEBUG 1 /**< we debug all the time */
#endif
/**
* @def debug_msg
* @brief A macro that prints the debug msg, as the same with @a printf.
*
*/
#ifdef DEBUG
#define debug_msg(fmt, ...) \
fprintf(stdout, fmt, ##__VA_ARGS__)
#else
#define debug_msg(fmt, ...)
#endif /* DEBUG */
#ifndef TRACE
#define TRACE 1 /**< we trace all the time */
#endif
/**
* @def debug_trace
* @brief A macro that traces the @p file, @p function and @p line.
*
*/
#ifdef TRACE
#define debug_trace(trace) \
fprintf(stdout, "%s File:%s Line:%d Func:%s.\n", \
trace, __FILE__, __LINE__, __func__)
#else
#define debug_trace(trace)
#endif
#endif /* _DEBUG_MSG_H */
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。