Fix and enable LUCY_DEBUG under MSVC Switch to ISO variadic macros.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/df927348 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/df927348 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/df927348 Branch: refs/heads/master Commit: df92734893823ff0d917ba582586100579f17163 Parents: a876a98 Author: Nick Wellnhofer <[email protected]> Authored: Mon Jan 2 16:16:19 2017 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Mon Jan 2 16:33:33 2017 +0100 ---------------------------------------------------------------------- common/charmonizer.c | 8 ++++---- common/charmonizer.main | 8 ++++---- core/Lucy/Util/Debug.cfh | 30 ++++++++++++++---------------- 3 files changed, 22 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/df927348/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/common/charmonizer.c b/common/charmonizer.c index f74a45f..8878f6c 100644 --- a/common/charmonizer.c +++ b/common/charmonizer.c @@ -8788,15 +8788,15 @@ static void S_add_compiler_flags(struct chaz_CLI *cli) { chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags(); + if (getenv("LUCY_DEBUG")) { + chaz_CFlags_add_define(extra_cflags, "LUCY_DEBUG", NULL); + } + if (chaz_Probe_gcc_version_num()) { if (getenv("LUCY_VALGRIND")) { chaz_CFlags_append(extra_cflags, "-DLUCY_VALGRIND -fno-inline-functions"); } - else if (getenv("LUCY_DEBUG")) { - chaz_CFlags_append(extra_cflags, "-DLUCY_DEBUG"); - } - chaz_CFlags_append(extra_cflags, "-pedantic -Wall -Wextra -Wno-variadic-macros"); if (chaz_CLI_defined(cli, "enable-perl")) { http://git-wip-us.apache.org/repos/asf/lucy/blob/df927348/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/common/charmonizer.main b/common/charmonizer.main index a2a1f13..cb8f0e6 100644 --- a/common/charmonizer.main +++ b/common/charmonizer.main @@ -184,15 +184,15 @@ static void S_add_compiler_flags(struct chaz_CLI *cli) { chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags(); + if (getenv("LUCY_DEBUG")) { + chaz_CFlags_add_define(extra_cflags, "LUCY_DEBUG", NULL); + } + if (chaz_Probe_gcc_version_num()) { if (getenv("LUCY_VALGRIND")) { chaz_CFlags_append(extra_cflags, "-DLUCY_VALGRIND -fno-inline-functions"); } - else if (getenv("LUCY_DEBUG")) { - chaz_CFlags_append(extra_cflags, "-DLUCY_DEBUG"); - } - chaz_CFlags_append(extra_cflags, "-pedantic -Wall -Wextra -Wno-variadic-macros"); if (chaz_CLI_defined(cli, "enable-perl")) { http://git-wip-us.apache.org/repos/asf/lucy/blob/df927348/core/Lucy/Util/Debug.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Util/Debug.cfh b/core/Lucy/Util/Debug.cfh index 1b61594..870660b 100644 --- a/core/Lucy/Util/Debug.cfh +++ b/core/Lucy/Util/Debug.cfh @@ -70,8 +70,8 @@ __C__ /** Unconditionally print debug statement prepending file and line info. */ -#define LUCY_DEBUG_PRINT(args...) \ - lucy_Debug_print_mess(__FILE__, __LINE__, __func__, ##args) +#define LUCY_DEBUG_PRINT(...) \ + lucy_Debug_print_mess(__FILE__, __LINE__, __func__, ##__VA_ARGS__) /** Conditionally execute code if debugging enabled via LUCY_DEBUG environment * variable. @@ -93,34 +93,32 @@ __C__ /** Conditionally print debug statement depending on LUCY_DEBUG env variable. */ -#define LUCY_DEBUG(args...) \ - LUCY_DEBUG_DO(LUCY_DEBUG_PRINT(args)); +#define LUCY_DEBUG(...) \ + LUCY_DEBUG_DO(LUCY_DEBUG_PRINT(__VA_ARGS__)); /** Abort on error if test fails. * * Note: unlike the system assert(), this [](cfish:.ASSERT) is #ifdef LUCY_DEBUG. */ -#define LUCY_ASSERT(test , args...) \ - do { \ - if (!(test)) { \ - LUCY_DEBUG_PRINT("ASSERT FAILED (" #test ")\n" args); \ - abort(); \ - } \ +#define LUCY_ASSERT(test, ...) \ + do { \ + if (!(test)) { \ + LUCY_DEBUG_PRINT("ASSERT FAILED (" #test ")\n", ##__VA_ARGS__); \ + abort(); \ + } \ } while (0) -#elif defined(CFISH_HAS_GNUC_VARIADIC_MACROS) // not LUCY_DEBUG +#elif defined(CFISH_HAS_ISO_VARIADIC_MACROS) // not LUCY_DEBUG -#undef LUCY_DEBUG #define LUCY_DEBUG_ENABLED 0 #define LUCY_DEBUG_DO(actions) #define LUCY_IFDEF_DEBUG(actions) -#define LUCY_DEBUG_PRINT(args...) -#define LUCY_DEBUG(args...) -#define LUCY_ASSERT(test, args...) +#define LUCY_DEBUG_PRINT(...) +#define LUCY_DEBUG(...) +#define LUCY_ASSERT(test, ...) #else // also not LUCY_DEBUG -#undef LUCY_DEBUG #define LUCY_DEBUG_ENABLED 0 #define LUCY_DEBUG_DO(actions) #define LUCY_IFDEF_DEBUG(actions)
