From 220d44f961b0813b2786e45e069660dd37d15f67 Mon Sep 17 00:00:00 2001 From: Tharre Date: Tue, 26 Jul 2016 12:33:47 +0200 Subject: Always show debug() statements to the compiler --- src/dbg.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dbg.h b/src/dbg.h index 961128f..902d885 100644 --- a/src/dbg.h +++ b/src/dbg.h @@ -1,6 +1,6 @@ /* dbg.h * - * Copyright (c) 2014 Tharre + * Copyright (c) 2014-2016 Tharre * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. @@ -19,6 +19,12 @@ #define _FILENAME __FILE__ #endif +#ifndef NDEBUG +#define DEBUG 1 +#else +#define DEBUG 0 +#endif + /* helper functions which help in replacing the GNU extension ##__VA_ARGS__ */ #define STRINGIFY(x) #x #define PREFIX(...) PREFIX_HELPER(_FILENAME, __LINE__, __VA_ARGS__) @@ -34,11 +40,7 @@ #define PREFIX_HELPER(f,l,...) "(" f ":" STRINGIFY(l) "): " __VA_ARGS__ #endif -#ifdef NDEBUG -#define debug(...) -#else -#define debug(...) log_err(__VA_ARGS__) -#endif +#define debug(...) do { if (DEBUG) log_err(__VA_ARGS__); } while (0) #define assert_str_equal(a,b) ({ \ if (strcmp(a, b)) { \ -- cgit v1.2.3-70-g09d2