From ef988f479b7cc460b9993c709039f4b2395a2caf Mon Sep 17 00:00:00 2001 From: mquinson Date: Tue, 8 Mar 2005 21:28:45 +0000 Subject: [PATCH 1/1] Buglet found by Loris: XBT_LOG_NEW_CATEGORY shouldn't produce warnings git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1168 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/xbt/log.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/include/xbt/log.h b/include/xbt/log.h index 9bb6e7723e..3c7e846e77 100644 --- a/include/xbt/log.h +++ b/include/xbt/log.h @@ -74,6 +74,16 @@ typedef enum { /* The root of the category hierarchy. */ #define XBT_LOG_ROOT_CAT root +/* XBT_LOG_NEW_SUBCATEGORY_helper: + * Implementation of XBT_LOG_NEW_SUBCATEGORY, which must declare "extern parent" in addition + * to avoid an extra declaration of root when XBT_LOG_NEW_SUBCATEGORY is called by + * XBT_LOG_NEW_CATEGORY */ +#define XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \ + s_xbt_log_category_t _XBT_LOGV(catName) = { \ + &_XBT_LOGV(parent), 0, 0, \ + #catName, xbt_log_priority_uninitialized, 1, \ + 0, 1 \ + } /** * \ingroup XBT_log * \param catName name of new category @@ -82,13 +92,9 @@ typedef enum { * * Defines a new subcategory of the parent. */ -#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \ - extern s_xbt_log_category_t _XBT_LOGV(parent); \ - s_xbt_log_category_t _XBT_LOGV(catName) = { \ - &_XBT_LOGV(parent), 0, 0, \ - #catName, xbt_log_priority_uninitialized, 1, \ - 0, 1 \ - } +#define XBT_LOG_NEW_SUBCATEGORY(catName, parent, desc) \ + extern s_xbt_log_category_t _XBT_LOGV(parent); \ + XBT_LOG_NEW_SUBCATEGORY_helper(catName, parent, desc) \ /** * \ingroup XBT_log @@ -97,7 +103,7 @@ typedef enum { * * Creates a new subcategory of the root category. */ -#define XBT_LOG_NEW_CATEGORY(catName,desc) XBT_LOG_NEW_SUBCATEGORY(catName, XBT_LOG_ROOT_CAT, desc) +#define XBT_LOG_NEW_CATEGORY(catName,desc) XBT_LOG_NEW_SUBCATEGORY_helper(catName, XBT_LOG_ROOT_CAT, desc) /** * \ingroup XBT_log -- 2.20.1