- * In strict ansi C, we are allowed to initialize a variable with "a
- * pointer to an lvalue designating an object of static storage
- * duration" [ISO/IEC 9899:1999, Section 6.6].
- *
- * Unfortunately, Visual C builder does not target any standard
- * compliance, and C99 is not an exception to this unfortunate rule.
- *
- * So, we work this around by adding a XBT_LOG_CONNECT() macro,
- * allowing to connect a child to its parent. It should be used
- * during the initialization of the code, before the child category
- * gets used.
- *
- * When compiling with gcc, this is not necessary (XBT_LOG_CONNECT
- * defines to nothing). When compiling with MSVC, this is needed if
- * you don't want to see your child category become a child of root
- * directly.
- */
-#if defined(_MSC_VER)
-# define _XBT_LOG_PARENT_INITIALIZER(parent) NULL
-# define XBT_LOG_CONNECT(child, parent_cat) \
- if (1) { \
- XBT_LOG_EXTERNAL_CATEGORY(child); \
- XBT_LOG_EXTERNAL_CATEGORY(parent_cat); \
- _XBT_LOGV(child).parent = &_XBT_LOGV(parent_cat); \
- } else ((void)0)
-#else
-# define _XBT_LOG_PARENT_INITIALIZER(parent) &_XBT_LOGV(parent)
-# define XBT_LOG_CONNECT(child, parent_cat) \
- if (1) { \
- XBT_LOG_EXTERNAL_CATEGORY(child); \
- XBT_LOG_EXTERNAL_CATEGORY(parent_cat); \
- xbt_assert(_XBT_LOGV(child).parent == &_XBT_LOGV(parent_cat)); \
+ * It is however necessary to make this connections as early as possible, if we
+ * want the category to be listed by --help-log-categories.
+ *
+ * When possible, the initializations takes place automatically before the start
+ * of main(). It's the case when compiling with gcc.
+ *
+ * For the other cases, you can use the XBT_LOG_CONNECT(cat) macro to force
+ * early initialization. See, for example, in xbt/log.c, the function
+ * xbt_log_connect_categories().
+ */
+
+#define XBT_LOG_CONNECT(cat) \
+ if (1) { \
+ extern void _XBT_LOGV_CTOR(cat)(void); \
+ _XBT_LOGV_CTOR(cat)(); \