Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

禁止输出时编译错误 #46

Closed
mojinpan opened this issue Mar 29, 2019 · 5 comments
Closed

禁止输出时编译错误 #46

mojinpan opened this issue Mar 29, 2019 · 5 comments

Comments

@mojinpan
Copy link

在elog.h中elog_a~elog_v的宏定义默认给出了有效定义(187-192行),导致未定义ELOG_OUTPUT_ENABLE时不能将宏有效置空。

@armink
Copy link
Owner

armink commented Mar 30, 2019

刚修正了,你再试试,多谢反馈哈~

@mojinpan
Copy link
Author

应该是把elog.h中elog_a~elog_v的宏定义默认给出了有效定义(187-192行),移至78行#else /* ELOG_OUTPUT_ENABLE /的后面:如下:
……
#ifndef ELOG_OUTPUT_ENABLE
#define elog_a(tag, ...)
#define elog_e(tag, ...)
#define elog_w(tag, ...)
#define elog_i(tag, ...)
#define elog_d(tag, ...)
#define elog_v(tag, ...)
#else /
ELOG_OUTPUT_ENABLE */
#define elog_a(tag, ...) elog_assert(tag, VA_ARGS)
#define elog_e(tag, ...) elog_error(tag, VA_ARGS)
#define elog_w(tag, ...) elog_warn(tag, VA_ARGS)
#define elog_i(tag, ...) elog_info(tag, VA_ARGS)
#define elog_d(tag, ...) elog_debug(tag, VA_ARGS)
#define elog_v(tag, ...) elog_verbose(tag, VA_ARGS)
……

@armink
Copy link
Owner

armink commented Mar 30, 2019

都行的,之前这个位置的定义写错了,所以修正下就行了

#ifndef ELOG_OUTPUT_ENABLE
#define elog_a(tag, ...)
#define elog_e(tag, ...)
#define elog_w(tag, ...)
#define elog_i(tag, ...)
#define elog_d(tag, ...)
#define elog_v(tag, ...)
#else /* ELOG_OUTPUT_ENABLE */

@mojinpan
Copy link
Author

实际上是不行的,原文结构如下;

……
#ifndef ELOG_OUTPUT_ENABLE
    #define elog_a(tag, ...)
    #define elog_e(tag, ...)
    #define elog_w(tag, ...)
    #define elog_i(tag, ...)
    #define elog_d(tag, ...)
    #define elog_v(tag, ...)
#else /* ELOG_OUTPUT_ENABLE */
……
#endif /* ELOG_OUTPUT_ENABLE */
……
#define elog_a(tag, ...)     elog_assert(tag, __VA_ARGS__)
#define elog_e(tag, ...)     elog_error(tag, __VA_ARGS__)
#define elog_w(tag, ...)     elog_warn(tag, __VA_ARGS__)
#define elog_i(tag, ...)     elog_info(tag, __VA_ARGS__)
#define elog_d(tag, ...)     elog_debug(tag, __VA_ARGS__)
#define elog_v(tag, ...)     elog_verbose(tag, __VA_ARGS__)
……

无论#ifndef ELOG_OUTPUT_ENABLE 是否生效,最后面的elog_a~elog_v的定义均生效,导致错误,这部分内容必须放到:

#else /* ELOG_OUTPUT_ENABLE */
……
#endif /* ELOG_OUTPUT_ENABLE */

@armink
Copy link
Owner

armink commented Mar 30, 2019

你可以更新下来试试嘛,我这边测试没问题

改动位于:6734e93

@armink armink closed this as completed Mar 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants